pretty happy with ladder movement right now
This commit is contained in:
@@ -3,6 +3,7 @@ extends RigidBody3D
|
||||
var despawning = false
|
||||
var despawn_time_s = 10
|
||||
|
||||
var mesh_activated = false
|
||||
var value
|
||||
@export_enum("Ammo", "Stamina", "Health", "Money","Weapon") var pickup_type: int
|
||||
var ammo_type
|
||||
@@ -23,7 +24,7 @@ var ammo_type
|
||||
@onready var money: Node3D = $Meshes/money
|
||||
|
||||
|
||||
var magnetable = true #false
|
||||
var magnetable = false
|
||||
var pickupable = false
|
||||
var pick_up = false
|
||||
var rand_amt
|
||||
@@ -32,41 +33,21 @@ var player
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
add_to_group("spawned")
|
||||
add_to_group("persist")
|
||||
|
||||
#Enable mesh
|
||||
match pickup_type:
|
||||
0:
|
||||
match ammo_type:
|
||||
0:
|
||||
light_ammo.visible = true
|
||||
1:
|
||||
medium_ammo.visible = true #medium
|
||||
2:
|
||||
heavy_ammo.visible = true #heavy
|
||||
3:
|
||||
shotgun_ammo.visible = true #shotgun
|
||||
4:
|
||||
rocket.visible = true #rocket
|
||||
1:
|
||||
stamina.visible = true
|
||||
2:
|
||||
health.visible = true
|
||||
3:
|
||||
money.visible = true
|
||||
|
||||
|
||||
if despawning == true:
|
||||
timer.wait_time = despawn_time_s
|
||||
timer.start()
|
||||
|
||||
func _physics_process(delta):
|
||||
if !mesh_activated:
|
||||
activate_mesh()
|
||||
|
||||
if player_follow != null:
|
||||
if !pick_up:
|
||||
despawning = false
|
||||
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
|
||||
position = lerp(position, player.item_holder.global_position, 25 * delta)
|
||||
if magnetable:
|
||||
despawning = false
|
||||
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
|
||||
position = lerp(position, player.item_holder.global_position, 25 * delta)
|
||||
|
||||
if abs(position - player.item_holder.global_position) < Vector3(.5,.5,.5):
|
||||
await get_tree().create_timer(1).timeout
|
||||
@@ -91,12 +72,36 @@ func save():
|
||||
"rot_x" : rotation.x,
|
||||
"rot_y" : rotation.y,
|
||||
"rot_z" : rotation.z,
|
||||
"linear_velocity" : linear_velocity,
|
||||
"angular_velocity" : angular_velocity,
|
||||
"pickup_type" : pickup_type,
|
||||
"ammo_type" : ammo_type,
|
||||
"value" : value
|
||||
}
|
||||
return save_dict
|
||||
|
||||
func activate_mesh():
|
||||
match pickup_type:
|
||||
0:
|
||||
match ammo_type:
|
||||
0:
|
||||
light_ammo.visible = true
|
||||
1:
|
||||
medium_ammo.visible = true #medium
|
||||
2:
|
||||
heavy_ammo.visible = true #heavy
|
||||
3:
|
||||
shotgun_ammo.visible = true #shotgun
|
||||
4:
|
||||
rocket.visible = true #rocket
|
||||
1:
|
||||
stamina.visible = true
|
||||
2:
|
||||
health.visible = true
|
||||
3:
|
||||
money.visible = true
|
||||
|
||||
mesh_activated = true
|
||||
|
||||
func _on_magnet_timer_timeout() -> void:
|
||||
magnetable = true
|
||||
|
||||
Reference in New Issue
Block a user