Compare commits
3 commits
3e571e7482
...
e32e7dca24
| Author | SHA1 | Date | |
|---|---|---|---|
| e32e7dca24 | |||
| ba2b7c8dda | |||
| b1cbbb1312 |
5 changed files with 75 additions and 117 deletions
|
|
@ -9,51 +9,23 @@ func use_basis():
|
||||||
|
|
||||||
# multiplier of player's speed
|
# multiplier of player's speed
|
||||||
const speed = 2
|
const speed = 2
|
||||||
# how far the vehicle lifts the player off the ground
|
|
||||||
const lift = 2
|
|
||||||
|
|
||||||
var box = null
|
|
||||||
var driver = null
|
var driver = null
|
||||||
var active = false
|
var active = false
|
||||||
|
|
||||||
func init_driver(player):
|
func on_use(player):
|
||||||
driver = player
|
driver = player
|
||||||
if not box:
|
if active:
|
||||||
box = Vector3(driver.get_node("CollisionShape3D").shape.size)
|
active = false
|
||||||
|
position = Vector3.ZERO
|
||||||
func mount():
|
driver.message("You are no longer driving a Geep")
|
||||||
|
return
|
||||||
active = true
|
active = true
|
||||||
position = Vector3(-driver.get_node("Pivot/Container").position)
|
position = Vector3(-driver.get_node("Pivot/Container").position)
|
||||||
position.y += 1
|
driver.message("You are now driving a Geep")
|
||||||
driver.message(
|
|
||||||
"Press [%s] to exit the Geep"
|
|
||||||
% Util.input_action_string("gear_use"))
|
|
||||||
driver.get_node("CameraGimbal").position.y += lift
|
|
||||||
driver.get_node("Pivot/Mesh").position.y += lift
|
|
||||||
driver.get_node("CollisionShape3D").shape.size = $GearMesh/Vehicle/CollisionShape3D.shape.size
|
|
||||||
driver.protected = true
|
|
||||||
driver.suspended = true
|
|
||||||
|
|
||||||
func unmount():
|
|
||||||
active = false
|
|
||||||
position = Vector3.ZERO
|
|
||||||
driver.message("")
|
|
||||||
driver.get_node("CameraGimbal").position = Vector3.ZERO
|
|
||||||
driver.get_node("Pivot/Mesh").position = Vector3.ZERO
|
|
||||||
driver.get_node("CollisionShape3D").shape.size = box
|
|
||||||
driver.protected = false
|
|
||||||
driver.suspended = false
|
|
||||||
|
|
||||||
func on_use(player):
|
|
||||||
init_driver(player)
|
|
||||||
if active:
|
|
||||||
unmount()
|
|
||||||
else:
|
|
||||||
mount()
|
|
||||||
|
|
||||||
func on_unequip(player):
|
func on_unequip(player):
|
||||||
init_driver(player)
|
active = false
|
||||||
unmount()
|
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
if not active:
|
if not active:
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,30 @@
|
||||||
[gd_scene load_steps=10 format=3 uid="uid://d3k7b6o56ue5k"]
|
[gd_scene load_steps=10 format=3 uid="uid://d3k7b6o56ue5k"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://fljad0m3jlt0" path="res://gears/geep.gd" id="1_8skgp"]
|
[ext_resource type="Script" uid="uid://fljad0m3jlt0" path="res://gears/geep.gd" id="1_8skgp"]
|
||||||
[ext_resource type="Material" uid="uid://dpacu3e7vsks5" path="res://gears/geep_body.tres" id="2_rhiad"]
|
|
||||||
[ext_resource type="Material" uid="uid://bt5aat64e478k" path="res://gears/geep_wheel.tres" id="3_lrfuo"]
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_lrfuo"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_8skgp"]
|
||||||
size = Vector3(3, 3, 6)
|
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_rhiad"]
|
|
||||||
material = ExtResource("2_rhiad")
|
|
||||||
size = Vector3(3, 0.5, 6)
|
size = Vector3(3, 0.5, 6)
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_kyikt"]
|
[sub_resource type="BoxMesh" id="BoxMesh_rhiad"]
|
||||||
material = ExtResource("2_rhiad")
|
size = Vector3(3, 0.5, 6)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_lrfuo"]
|
||||||
size = Vector3(0.5, 1.75, 6)
|
size = Vector3(0.5, 1.75, 6)
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_wm067"]
|
[sub_resource type="BoxMesh" id="BoxMesh_kyikt"]
|
||||||
material = ExtResource("2_rhiad")
|
size = Vector3(0.5, 1.75, 6)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_vjakw"]
|
||||||
size = Vector3(3, 2, 2.5)
|
size = Vector3(3, 2, 2.5)
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"]
|
[sub_resource type="BoxMesh" id="BoxMesh_wm067"]
|
||||||
material = ExtResource("2_rhiad")
|
size = Vector3(3, 2, 2.5)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_rhiad"]
|
||||||
size = Vector3(3, 2, 0.5)
|
size = Vector3(3, 2, 0.5)
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_lrfuo"]
|
[sub_resource type="BoxMesh" id="BoxMesh_lrfuo"]
|
||||||
material = ExtResource("3_lrfuo")
|
size = Vector3(3, 2, 0.5)
|
||||||
top_radius = 1.0
|
|
||||||
bottom_radius = 1.0
|
|
||||||
height = 0.25
|
|
||||||
|
|
||||||
[node name="Gear" type="Node3D"]
|
[node name="Gear" type="Node3D"]
|
||||||
rotation_edit_mode = 2
|
rotation_edit_mode = 2
|
||||||
|
|
@ -42,46 +39,44 @@ one_shot = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1.0000001, 0, 0, 0, 1.0000001, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 1.0000001, 0, 0, 0, 1.0000001, 0, 0, 0)
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
[node name="BaseShape" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
shape = SubResource("BoxShape3D_8skgp")
|
||||||
shape = SubResource("BoxShape3D_lrfuo")
|
|
||||||
|
|
||||||
[node name="BaseMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
[node name="BaseMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9997004, 0)
|
|
||||||
mesh = SubResource("BoxMesh_rhiad")
|
mesh = SubResource("BoxMesh_rhiad")
|
||||||
|
|
||||||
|
[node name="LeftSideShape" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 1.1249999, 0)
|
||||||
|
shape = SubResource("BoxShape3D_lrfuo")
|
||||||
|
|
||||||
[node name="LeftSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
[node name="LeftSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 2.1247003, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, -1.25, 1.1249999, 0)
|
||||||
mesh = SubResource("BoxMesh_kyikt")
|
mesh = SubResource("BoxMesh_kyikt")
|
||||||
skeleton = NodePath("")
|
skeleton = NodePath("")
|
||||||
|
|
||||||
|
[node name="RightSideShape" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 1.1249999, 0)
|
||||||
|
shape = SubResource("BoxShape3D_lrfuo")
|
||||||
|
|
||||||
[node name="RightSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
[node name="RightSideMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 2.1247003, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.9999999, 0, 0, 0, 0.9999999, 1.25, 1.1249999, 0)
|
||||||
mesh = SubResource("BoxMesh_kyikt")
|
mesh = SubResource("BoxMesh_kyikt")
|
||||||
skeleton = NodePath("")
|
skeleton = NodePath("")
|
||||||
|
|
||||||
|
[node name="BonnetShape" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.75)
|
||||||
|
shape = SubResource("BoxShape3D_vjakw")
|
||||||
|
|
||||||
[node name="BonnetMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
[node name="BonnetMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, -1.75)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.75)
|
||||||
mesh = SubResource("BoxMesh_wm067")
|
mesh = SubResource("BoxMesh_wm067")
|
||||||
|
|
||||||
|
[node name="TailgateShape" type="CollisionShape3D" parent="GearMesh/Vehicle"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.75)
|
||||||
|
shape = SubResource("BoxShape3D_rhiad")
|
||||||
|
|
||||||
[node name="TailgateMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
[node name="TailgateMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9997005, 2.75)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 2.75)
|
||||||
mesh = SubResource("BoxMesh_lrfuo")
|
mesh = SubResource("BoxMesh_lrfuo")
|
||||||
|
|
||||||
[node name="WheelFLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
|
||||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, 2)
|
|
||||||
mesh = SubResource("CylinderMesh_lrfuo")
|
|
||||||
|
|
||||||
[node name="WheelFRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
|
||||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, 2)
|
|
||||||
mesh = SubResource("CylinderMesh_lrfuo")
|
|
||||||
|
|
||||||
[node name="WheelBLMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
|
||||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, 1.65, 1, -2)
|
|
||||||
mesh = SubResource("CylinderMesh_lrfuo")
|
|
||||||
|
|
||||||
[node name="WheelBRMesh" type="MeshInstance3D" parent="GearMesh/Vehicle"]
|
|
||||||
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 1, -1.65, 1, -2)
|
|
||||||
mesh = SubResource("CylinderMesh_lrfuo")
|
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
|
|
|
||||||
17
main.tscn
17
main.tscn
|
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=9 format=3 uid="uid://eiaw4xbs3suk"]
|
[gd_scene load_steps=10 format=3 uid="uid://eiaw4xbs3suk"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"]
|
[ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"]
|
[ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"]
|
[ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"]
|
||||||
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
|
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"]
|
[ext_resource type="PackedScene" uid="uid://c117buhmmkvkt" path="res://gears/ball.tscn" id="5_7mycd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d3k7b6o56ue5k" path="res://gears/geep.tscn" id="6_272bh"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
|
||||||
size = Vector3(100, 2, 100)
|
size = Vector3(100, 2, 100)
|
||||||
|
|
@ -18,7 +19,6 @@ albedo_color = Color(0.49454, 0.79, 0.4424, 1)
|
||||||
[node name="Main" type="Node3D"]
|
[node name="Main" type="Node3D"]
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("1_ig7tw")]
|
[node name="Player" parent="." instance=ExtResource("1_ig7tw")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
|
||||||
|
|
||||||
[node name="Baseplate" type="StaticBody3D" parent="."]
|
[node name="Baseplate" type="StaticBody3D" parent="."]
|
||||||
|
|
||||||
|
|
@ -48,8 +48,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 7, 0)
|
||||||
[node name="Killbrick" parent="." instance=ExtResource("1_h2yge")]
|
[node name="Killbrick" parent="." instance=ExtResource("1_h2yge")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -40, 1.5, -40)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -40, 1.5, -40)
|
||||||
|
|
||||||
[node name="GearPickup" parent="." instance=ExtResource("3_lquwl")]
|
[node name="BallPickup" parent="." instance=ExtResource("3_lquwl")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21)
|
||||||
|
|
||||||
[node name="Gear" parent="GearPickup" instance=ExtResource("4_7mycd")]
|
[node name="Gear" parent="BallPickup" instance=ExtResource("5_7mycd")]
|
||||||
transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0.5, 0)
|
|
||||||
|
[node name="GeepPickup" parent="." instance=ExtResource("3_lquwl")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, -20)
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="Gear" parent="GeepPickup" instance=ExtResource("6_272bh")]
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ const gear_slots = ["1", "2", "3"]
|
||||||
|
|
||||||
var starting_gear = preload("res://gears/gear.tscn")
|
var starting_gear = preload("res://gears/gear.tscn")
|
||||||
|
|
||||||
var dead = false
|
|
||||||
var protected = false
|
|
||||||
var suspended = false
|
var suspended = false
|
||||||
var direction = Vector3.ZERO
|
var direction = Vector3.ZERO
|
||||||
var target_velocity = Vector3.ZERO
|
var target_velocity = Vector3.ZERO
|
||||||
|
|
@ -47,8 +45,6 @@ func message(string):
|
||||||
# State functions
|
# State functions
|
||||||
|
|
||||||
func harm(hp):
|
func harm(hp):
|
||||||
if protected:
|
|
||||||
return
|
|
||||||
assert(hp >= 0)
|
assert(hp >= 0)
|
||||||
_health -= hp
|
_health -= hp
|
||||||
make_hud()
|
make_hud()
|
||||||
|
|
@ -61,8 +57,7 @@ func heal(hp):
|
||||||
func health():
|
func health():
|
||||||
return _health
|
return _health
|
||||||
|
|
||||||
func _die():
|
func die():
|
||||||
dead = true
|
|
||||||
suspended = true
|
suspended = true
|
||||||
visible = false
|
visible = false
|
||||||
$HUD.visible = false
|
$HUD.visible = false
|
||||||
|
|
@ -70,24 +65,18 @@ func _die():
|
||||||
# strip gears
|
# strip gears
|
||||||
for gear in $Backpack.get_children():
|
for gear in $Backpack.get_children():
|
||||||
gear.queue_free()
|
gear.queue_free()
|
||||||
if has_node("Pivot/Container/Gear"):
|
$Pivot/Container/Gear.unequip(self)
|
||||||
$Pivot/Container/Gear.unequip(self)
|
$Pivot/Container/Gear.queue_free()
|
||||||
$Pivot/Container/Gear.queue_free()
|
|
||||||
|
|
||||||
$RespawnTimer.start()
|
$RespawnTimer.start()
|
||||||
message("Le gone")
|
message("Le gone")
|
||||||
|
|
||||||
func die():
|
|
||||||
if protected:
|
|
||||||
return
|
|
||||||
_die()
|
|
||||||
|
|
||||||
func respawn():
|
func respawn():
|
||||||
position = Vector3(spawn)
|
position = Vector3(spawn)
|
||||||
$CameraGimbal.reset()
|
$CameraGimbal.reset()
|
||||||
_health = 100
|
_health = 100
|
||||||
visible = true
|
visible = true
|
||||||
dead = false
|
suspended = false
|
||||||
|
|
||||||
# add starting gear
|
# add starting gear
|
||||||
var gear = starting_gear.instantiate()
|
var gear = starting_gear.instantiate()
|
||||||
|
|
@ -195,17 +184,16 @@ func do_movement(delta):
|
||||||
var mx = 0
|
var mx = 0
|
||||||
var mz = 0
|
var mz = 0
|
||||||
|
|
||||||
if not suspended:
|
if Input.is_action_pressed("move_forward"):
|
||||||
if Input.is_action_pressed("move_forward"):
|
mz -= 1
|
||||||
mz -= 1
|
if Input.is_action_pressed("move_back"):
|
||||||
if Input.is_action_pressed("move_back"):
|
mz += 1
|
||||||
mz += 1
|
if Input.is_action_pressed("move_left"):
|
||||||
if Input.is_action_pressed("move_left"):
|
mx -= 1
|
||||||
mx -= 1
|
if Input.is_action_pressed("move_right"):
|
||||||
if Input.is_action_pressed("move_right"):
|
mx += 1
|
||||||
mx += 1
|
if Input.is_action_pressed("jump") and is_on_floor():
|
||||||
if Input.is_action_pressed("jump") and is_on_floor():
|
target_velocity.y = jump_power
|
||||||
target_velocity.y = jump_power
|
|
||||||
|
|
||||||
if !(mx == 0 and mz == 0):
|
if !(mx == 0 and mz == 0):
|
||||||
move_player(mx, mz)
|
move_player(mx, mz)
|
||||||
|
|
@ -238,11 +226,11 @@ func _ready():
|
||||||
respawn()
|
respawn()
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if dead:
|
|
||||||
return
|
|
||||||
|
|
||||||
if health() < 1 or position.y <= -1000:
|
if health() < 1 or position.y <= -1000:
|
||||||
_die()
|
die()
|
||||||
|
|
||||||
|
if suspended:
|
||||||
|
return
|
||||||
|
|
||||||
# Backpack keys
|
# Backpack keys
|
||||||
do_backpack_keys()
|
do_backpack_keys()
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,7 @@ shape = SubResource("BoxShape3D_onrkg")
|
||||||
|
|
||||||
[node name="Pivot" type="Node3D" parent="."]
|
[node name="Pivot" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Mesh" type="Node3D" parent="Pivot"]
|
[node name="PlayerMesh" type="MeshInstance3D" parent="Pivot"]
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Pivot/Mesh"]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, -100, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, -100, 0)
|
||||||
mesh = SubResource("ArrayMesh_sweqy")
|
mesh = SubResource("ArrayMesh_sweqy")
|
||||||
skeleton = NodePath("")
|
skeleton = NodePath("")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue