From cdb6dc3ff78516bdc1b10c2f02ac50973969b749 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Wed, 14 Sep 2022 10:35:49 -0400 Subject: Pilot ship with arrow keys --- World.gd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 World.gd (limited to 'World.gd') diff --git a/World.gd b/World.gd new file mode 100644 index 0000000..09b8e85 --- /dev/null +++ b/World.gd @@ -0,0 +1,16 @@ +extends RigidBody + +export var acceleration = 10.0; + +func travel(direction:Vector3): + var boat_direction = $"/root/Main/Raft".global_transform.basis + boat_direction = Basis(Vector3.UP*boat_direction.get_euler().y) + direction = -direction + direction = boat_direction * direction + direction = direction.normalized() + self.add_central_force(direction*acceleration) + +func _integrate_forces(_state): + var stick = Input.get_axis("ship_down","ship_up") + if stick != 0.0: + travel(Vector3.FORWARD*stick) -- cgit v1.2.3