2.7 rigidbody3d and physics
This commit is contained in:
parent
9cb699e626
commit
03b8155b52
2 changed files with 19 additions and 6 deletions
|
@ -1,18 +1,21 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class Player : Node3D
|
public partial class Player : RigidBody3D
|
||||||
{
|
{
|
||||||
|
private static Vector3 ZLeft = new Vector3(0.0f, 0.0f, 100.0f);
|
||||||
|
private static Vector3 ZRight = new Vector3(0.0f, 0.0f, -100.0f);
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
float fd = (float)delta;
|
||||||
if (Input.IsActionPressed("ui_accept")){
|
if (Input.IsActionPressed("ui_accept")){
|
||||||
Position += new Vector3(0, 1, 0) * (float)delta;
|
ApplyCentralForce(Basis.Y * fd * 1000.0f);
|
||||||
}
|
}
|
||||||
if (Input.IsActionPressed("ui_left")){
|
if (Input.IsActionPressed("ui_left")){
|
||||||
RotateZ((float)delta);
|
ApplyTorque(ZLeft * fd);
|
||||||
}
|
}
|
||||||
if (Input.IsActionPressed("ui_right")){
|
if (Input.IsActionPressed("ui_right")){
|
||||||
RotateZ(-(float)delta);
|
ApplyTorque(ZRight * fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://cuduv6fwqtocs"]
|
[gd_scene load_steps=4 format=3 uid="uid://cuduv6fwqtocs"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/characters/Player.cs" id="1_fr1bo"]
|
[ext_resource type="Script" path="res://scenes/characters/Player.cs" id="1_fr1bo"]
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_dk8lw"]
|
[sub_resource type="CylinderMesh" id="CylinderMesh_dk8lw"]
|
||||||
|
|
||||||
[node name="Player" type="Node3D"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_bplwn"]
|
||||||
|
|
||||||
|
[node name="Player" type="RigidBody3D"]
|
||||||
|
axis_lock_linear_z = true
|
||||||
|
axis_lock_angular_x = true
|
||||||
|
axis_lock_angular_y = true
|
||||||
|
linear_damp = 1.0
|
||||||
|
angular_damp = 3.0
|
||||||
script = ExtResource("1_fr1bo")
|
script = ExtResource("1_fr1bo")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
mesh = SubResource("CylinderMesh_dk8lw")
|
mesh = SubResource("CylinderMesh_dk8lw")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("CylinderShape3D_bplwn")
|
||||||
|
|
Loading…
Add table
Reference in a new issue