diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-09-14 10:35:49 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-09-15 08:57:23 -0400 |
commit | cdb6dc3ff78516bdc1b10c2f02ac50973969b749 (patch) | |
tree | 97e144fc1034c123bcd2fffa0e356fba82f8ffb9 | |
parent | 79b829e35ae65e3c046e7081aeb2557242e93d24 (diff) | |
download | game_jam49-cdb6dc3ff78516bdc1b10c2f02ac50973969b749.tar.gz game_jam49-cdb6dc3ff78516bdc1b10c2f02ac50973969b749.zip |
Pilot ship with arrow keys
-rw-r--r-- | Main.tscn | 18 | ||||
-rw-r--r-- | Raft.gd | 8 | ||||
-rw-r--r-- | World.gd | 16 | ||||
-rw-r--r-- | project.godot | 20 |
4 files changed, 61 insertions, 1 deletions
@@ -1,10 +1,12 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=17 format=2] [ext_resource path="res://character/fps_controller/fps_controller.tscn" type="PackedScene" id=1] [ext_resource path="res://ship/ship/ship.tscn" type="PackedScene" id=2] [ext_resource path="res://water/Water.tscn" type="PackedScene" id=3] [ext_resource path="res://Float.tscn" type="PackedScene" id=4] [ext_resource path="res://ship/ship/crate.tscn" type="PackedScene" id=5] +[ext_resource path="res://World.gd" type="Script" id=5] +[ext_resource path="res://Raft.gd" type="Script" id=6] [sub_resource type="BoxShape" id=19] extents = Vector3( 1000, 0.1, 1000 ) @@ -69,6 +71,7 @@ axis_lock_linear_x = true axis_lock_linear_z = true linear_damp = 2.0 angular_damp = 2.0 +script = ExtResource( 6 ) [node name="CollisionShape" type="CollisionShape" parent="ShipRigidBody"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.78898, 0 ) @@ -120,6 +123,19 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.77011, -3.30323, -49.022 ) [node name="crates" type="Spatial" parent="."] +[node name="World" type="RigidBody" parent="."] +collision_layer = 0 +collision_mask = 0 +axis_lock_linear_y = true +axis_lock_angular_x = true +axis_lock_angular_y = true +axis_lock_angular_z = true +linear_damp = 0.5 +script = ExtResource( 5 ) + +[node name="CollisionShape" type="CollisionShape" parent="World"] +shape = SubResource( 22 ) + [node name="crate" parent="crates" instance=ExtResource( 5 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56126, 0 ) @@ -0,0 +1,8 @@ +extends RigidBody + +export var ang_acceleration = 60.0 + +func _integrate_forces(_state): + var stick = Input.get_axis("ship_right","ship_left") + if stick != 0.0: + self.add_torque(Vector3.UP*stick*ang_acceleration) 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) diff --git a/project.godot b/project.godot index fcde3af..13b5902 100644 --- a/project.godot +++ b/project.godot @@ -76,6 +76,26 @@ jump={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) ] } +ship_up={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +ship_down={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +ship_left={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +ship_right={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} [physics] |