ladder kiiiiind of works
This commit is contained in:
24
scripts/ladder.gd
Normal file
24
scripts/ladder.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Node3D
|
||||
|
||||
var is_climbing = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
is_climbing = true
|
||||
body.lader_collide(is_climbing)
|
||||
|
||||
|
||||
func _on_area_3d_body_exited(body):
|
||||
if body.is_in_group("player"):
|
||||
is_climbing = false
|
||||
body.lader_collide(is_climbing)
|
||||
@@ -4,6 +4,7 @@ extends CharacterBody3D
|
||||
var speed
|
||||
var double_jump = true
|
||||
var gravity = 9.8
|
||||
var default_gravity = gravity
|
||||
var mouse_input : Vector2
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
@@ -277,6 +278,15 @@ func _on_pick_up_detection_body_entered(body):
|
||||
level_control.gun_spawn(weapon_id)
|
||||
|
||||
|
||||
func lader_collide(is_climbing):
|
||||
|
||||
if is_climbing == true:
|
||||
if Input.is_action_pressed("move_up"):
|
||||
velocity.y += 5
|
||||
gravity = 0.0
|
||||
else:
|
||||
gravity = default_gravity
|
||||
|
||||
func _on_pick_up_magnet_body_entered(body):
|
||||
if body.is_in_group("pickup") and body.is_in_group("magnet"):
|
||||
body.player = self
|
||||
|
||||
Reference in New Issue
Block a user