started work on wall jump

This commit is contained in:
Derek
2025-02-18 08:41:03 -06:00
parent ba0d9ce2f3
commit 2c6ef42d7b
2 changed files with 30 additions and 10 deletions

View File

@@ -313,6 +313,9 @@ libraries = {
"": SubResource("AnimationLibrary_d0x8a") "": SubResource("AnimationLibrary_d0x8a")
} }
[node name="velocity_ray" type="RayCast3D" parent="."]
transform = Transform3D(1, -2.21121e-11, 5.69206e-32, 2.21121e-11, 1, 0, -5.69206e-32, 1.25837e-42, 1, 0.000168126, -1.01843, -0.00105944)
[connection signal="tree_entered" from="." to="." method="_on_tree_entered"] [connection signal="tree_entered" from="." to="." method="_on_tree_entered"]
[connection signal="body_entered" from="pick_up_detection" to="." method="_on_pick_up_detection_body_entered"] [connection signal="body_entered" from="pick_up_detection" to="." method="_on_pick_up_detection_body_entered"]
[connection signal="body_entered" from="pick_up_magnet" to="." method="_on_pick_up_magnet_body_entered"] [connection signal="body_entered" from="pick_up_magnet" to="." method="_on_pick_up_magnet_body_entered"]

View File

@@ -2,7 +2,9 @@ extends CharacterBody3D
const JUMP_VELOCITY = 5 const JUMP_VELOCITY = 5
const JUMP_WEAPON_DIP = Vector3(0,-5,0) const JUMP_WEAPON_DIP = Vector3(0,-5,0)
const WALK_TRANSITION_SPEED = 7 const AIR_TRANSITION_SPEED = 7
const GROUND_TRANSITION_SPEED = 4
const MAX_AIR_DASH = 1 const MAX_AIR_DASH = 1
const FLASHLIGHT_BRIGHTNESS = 30 const FLASHLIGHT_BRIGHTNESS = 30
const KICK_AMOUNT = 20 const KICK_AMOUNT = 20
@@ -30,6 +32,7 @@ const L_JOYSTICK_DEADZONE = .2
const L_JOYSTICK_SENSITIVITY = .1 const L_JOYSTICK_SENSITIVITY = .1
var speed var speed
var walk_transition_speed
var double_jump = true var double_jump = true
var air_dash = MAX_AIR_DASH var air_dash = MAX_AIR_DASH
var gravity = 9.8 var gravity = 9.8
@@ -70,6 +73,7 @@ var gun_is_holstered = false
@onready var level_control = get_tree().current_scene @onready var level_control = get_tree().current_scene
@onready var interact_ray = $Head/Recoil/Camera3D/InteractRay @onready var interact_ray = $Head/Recoil/Camera3D/InteractRay
@onready var bullet_ray = $Head/Recoil/Camera3D/BulletRay @onready var bullet_ray = $Head/Recoil/Camera3D/BulletRay
@onready var velocity_ray: RayCast3D = $velocity_ray
@onready var hitmarker = load("res://hitmarker.tscn") @onready var hitmarker = load("res://hitmarker.tscn")
var instance_bullet var instance_bullet
var instance_casing var instance_casing
@@ -216,11 +220,14 @@ func _physics_process(delta):
# Handle jump. # Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor() and !is_climbing: if Input.is_action_just_pressed("jump"):
if is_on_floor() and !is_climbing:
velocity.y += JUMP_VELOCITY velocity.y += JUMP_VELOCITY
weapon_dip_pos += JUMP_WEAPON_DIP weapon_dip_pos += JUMP_WEAPON_DIP
crouched = false crouched = false
elif Input.is_action_just_pressed("jump") and double_jump == true and !is_climbing: elif wall_jump():
velocity += 2 * Vector3(-velocity.x,10,-velocity.z)
elif double_jump == true and !is_climbing:
velocity.y += JUMP_VELOCITY velocity.y += JUMP_VELOCITY
double_jump = false double_jump = false
@@ -263,9 +270,10 @@ func _physics_process(delta):
#walking #walking
if is_on_floor() and !is_climbing: if is_on_floor() and !is_climbing:
walk_transition_speed = AIR_TRANSITION_SPEED
if direction: if direction:
velocity.x = lerp(velocity.x, direction.x * speed, delta * WALK_TRANSITION_SPEED) velocity.x = lerp(velocity.x, direction.x * speed, delta * walk_transition_speed)
velocity.z = lerp(velocity.z, direction.z * speed, delta * WALK_TRANSITION_SPEED) velocity.z = lerp(velocity.z, direction.z * speed, delta * walk_transition_speed)
else: else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * DASH_SPEED) velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * DASH_SPEED)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * DASH_SPEED) velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * DASH_SPEED)
@@ -551,6 +559,15 @@ func ladder_collide():
else: else:
gravity = default_gravity 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
else:
return false
## VARIOUS ACTIONS ## VARIOUS ACTIONS
func flashlight_toggle(): func flashlight_toggle():
if flashlight_on: if flashlight_on: