added wall running and jumping
This commit is contained in:
@@ -51,7 +51,7 @@ func _input(event):
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
Engine.time_scale = .01
|
||||
Engine.time_scale = .02
|
||||
player.gamespeed_controlled = true
|
||||
player.controlled_elsewhere = true
|
||||
player_cam_FOV = player.camera.fov
|
||||
@@ -78,7 +78,7 @@ func _physics_process(delta):
|
||||
if Input.is_action_pressed("sprint"):
|
||||
Engine.time_scale = .05
|
||||
else:
|
||||
Engine.time_scale = .01
|
||||
Engine.time_scale = .02
|
||||
|
||||
focus_on_target()
|
||||
|
||||
@@ -117,6 +117,7 @@ func focus_on_target():
|
||||
camera.attributes.dof_blur_far_enabled = true
|
||||
camera.attributes.dof_blur_far_distance = camera.global_position.distance_to(cam_ray.get_collision_point()) + 5.0
|
||||
camera.attributes.dof_blur_near_enabled = true
|
||||
camera.attributes.dof_blur_near_distance = camera.global_position.distance_to(cam_ray.get_collision_point()) - 10.0
|
||||
camera.attributes.dof_blur_amount = lerp(0.0,BLUR_AMOUNT,1.0 - Engine.time_scale)
|
||||
|
||||
func log_path(delta):
|
||||
@@ -130,17 +131,17 @@ func log_path(delta):
|
||||
record_id += 1
|
||||
|
||||
func despawn():
|
||||
var read_record = record_id - 1
|
||||
for i in bullet_path:
|
||||
if read_record > 1:
|
||||
camera.global_position = lerp(bullet_path[read_record]["global_position"],bullet_path[read_record-1]["global_position"],bullet_path[read_record]["delta"])
|
||||
await get_tree().create_timer(bullet_path[read_record]["delta"]).timeout
|
||||
read_record -= 1
|
||||
if read_record <= 0:
|
||||
player.camera.current = true
|
||||
player.controlled_elsewhere = false
|
||||
player.gamespeed_controlled = false
|
||||
##visible = false
|
||||
##collision_shape.disabled = true
|
||||
##await get_tree().create_timer(1).timeout
|
||||
queue_free()
|
||||
#var read_record = record_id - 1
|
||||
#for i in bullet_path:
|
||||
#if read_record > 1:
|
||||
#camera.global_position = lerp(bullet_path[read_record]["global_position"],bullet_path[read_record-1]["global_position"],bullet_path[read_record]["delta"])
|
||||
#await get_tree().create_timer(bullet_path[read_record]["delta"]).timeout
|
||||
#read_record -= 1
|
||||
#if read_record <= 0:
|
||||
player.camera.current = true
|
||||
player.controlled_elsewhere = false
|
||||
player.gamespeed_controlled = false
|
||||
##visible = false
|
||||
##collision_shape.disabled = true
|
||||
##await get_tree().create_timer(1).timeout
|
||||
queue_free()
|
||||
|
||||
@@ -73,7 +73,9 @@ var gun_is_holstered = false
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var interact_ray = $Head/Recoil/Camera3D/InteractRay
|
||||
@onready var bullet_ray = $Head/Recoil/Camera3D/BulletRay
|
||||
@onready var velocity_ray: RayCast3D = $velocity_ray
|
||||
@onready var wall_ray_1: RayCast3D = $wall_ray1
|
||||
@onready var wall_ray_2: RayCast3D = $wall_ray2
|
||||
@onready var wall_ray_3: RayCast3D = $wall_ray3
|
||||
@onready var hitmarker = load("res://hitmarker.tscn")
|
||||
var instance_bullet
|
||||
var instance_casing
|
||||
@@ -112,6 +114,10 @@ var held_key_check = 0.0
|
||||
|
||||
# Slow Down Variables
|
||||
var remaining_stamina : float = MAX_STAMINA
|
||||
|
||||
# Wall Jump
|
||||
var can_wall_jump = true
|
||||
|
||||
# Pickups
|
||||
var picked_up = false
|
||||
var picked_up_text
|
||||
@@ -156,6 +162,7 @@ var controlled_elsewhere = false
|
||||
@onready var hud: Control = $Head/Recoil/Camera3D/HUD
|
||||
@onready var clock_sound: AudioStreamPlayer = $Audio/ClockSound
|
||||
@onready var weapon_select_menu: Control = $Head/Recoil/Camera3D/WeaponSelect
|
||||
@onready var wall_jump_timer: Timer = $WallJumpTimer
|
||||
|
||||
|
||||
func _ready():
|
||||
@@ -208,7 +215,6 @@ func _physics_process(delta):
|
||||
|
||||
if !dead and !level_control.paused:
|
||||
|
||||
|
||||
# Add the gravity.
|
||||
if is_on_floor():
|
||||
double_jump = true
|
||||
@@ -226,7 +232,7 @@ func _physics_process(delta):
|
||||
weapon_dip_pos += JUMP_WEAPON_DIP
|
||||
crouched = false
|
||||
elif wall_jump():
|
||||
velocity += 2 * Vector3(-velocity.x,10,-velocity.z)
|
||||
velocity += Vector3(velocity.x * 5,10,velocity.z * 5)
|
||||
elif double_jump == true and !is_climbing:
|
||||
velocity.y += JUMP_VELOCITY
|
||||
double_jump = false
|
||||
@@ -249,7 +255,17 @@ func _physics_process(delta):
|
||||
velocity.x += direction.x * DASH_SPEED
|
||||
velocity.z += direction.z * DASH_SPEED
|
||||
air_dash -= 1
|
||||
|
||||
|
||||
if Input.is_action_pressed("move_left"):
|
||||
wall_ray_1.enabled = true
|
||||
else:
|
||||
wall_ray_1.enabled = false
|
||||
|
||||
if Input.is_action_pressed("move_right"):
|
||||
wall_ray_2.enabled = true
|
||||
else:
|
||||
wall_ray_2.enabled = false
|
||||
|
||||
if Input.is_action_just_pressed("crouch"):
|
||||
if crouched:
|
||||
if !crouch_check.is_colliding():
|
||||
@@ -290,6 +306,12 @@ func _physics_process(delta):
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
|
||||
## wall_run
|
||||
if wall_ray_1.is_colliding() or wall_ray_2.is_colliding():
|
||||
if abs(Vector2(velocity.x,velocity.y)) >= Vector2(5.0,5.0):
|
||||
velocity.y = clamp(velocity.y,-2,abs(velocity.y))
|
||||
#velocity.x += -velocity.x * .01 * delta
|
||||
#velocity.z += -velocity.z * .01 * delta
|
||||
|
||||
# Head bob
|
||||
t_bob += delta * velocity.length() * float(is_on_floor())
|
||||
@@ -560,14 +582,20 @@ func ladder_collide():
|
||||
gravity = default_gravity
|
||||
|
||||
func wall_jump():
|
||||
velocity_ray.rotation = velocity.normalized()
|
||||
print("VELOCITY NORMALIZED: ",velocity.normalized())
|
||||
print("VELOCITY RAY ROTATION: ", velocity_ray.rotation)
|
||||
if velocity_ray.is_colliding():
|
||||
return true
|
||||
print("CAN JUMP? ",can_wall_jump)
|
||||
if can_wall_jump == true:
|
||||
if wall_ray_1.is_colliding() or wall_ray_2.is_colliding() or wall_ray_3.is_colliding():
|
||||
can_wall_jump = false
|
||||
wall_jump_timer.start()
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
else:
|
||||
return false
|
||||
|
||||
func _on_wall_jump_timer_timeout() -> void:
|
||||
can_wall_jump = true
|
||||
|
||||
## VARIOUS ACTIONS
|
||||
func flashlight_toggle():
|
||||
if flashlight_on:
|
||||
|
||||
Reference in New Issue
Block a user