added wall running
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=41 format=3 uid="uid://drwae3loscbw7"]
|
[gd_scene load_steps=42 format=3 uid="uid://drwae3loscbw7"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bieeh1iro4ji1" path="res://scripts/player.gd" id="1_x7wms"]
|
[ext_resource type="Script" uid="uid://bieeh1iro4ji1" path="res://scripts/player.gd" id="1_x7wms"]
|
||||||
[ext_resource type="Script" uid="uid://linvnr16djav" path="res://scripts/PlayerStateMachine.gd" id="2_1npgd"]
|
[ext_resource type="Script" uid="uid://linvnr16djav" path="res://scripts/PlayerStateMachine.gd" id="2_1npgd"]
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://dqgtnykkbngem" path="res://assets/weapon_select.tscn" id="5_bvbcl"]
|
[ext_resource type="PackedScene" uid="uid://dqgtnykkbngem" path="res://assets/weapon_select.tscn" id="5_bvbcl"]
|
||||||
[ext_resource type="Script" uid="uid://clyi3lxv4xt4g" path="res://scripts/player_jumping.gd" id="5_m0ick"]
|
[ext_resource type="Script" uid="uid://clyi3lxv4xt4g" path="res://scripts/player_jumping.gd" id="5_m0ick"]
|
||||||
[ext_resource type="PackedScene" uid="uid://br882tlh3cfwu" path="res://hud.tscn" id="5_yenaw"]
|
[ext_resource type="PackedScene" uid="uid://br882tlh3cfwu" path="res://hud.tscn" id="5_yenaw"]
|
||||||
|
[ext_resource type="Script" uid="uid://bgj2bqb5dys41" path="res://scripts/player_wall_running.gd" id="6_1npgd"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bki17g7j4kqn4" path="res://assets/Audio/PickupSound Mixdown 3.wav" id="8_dwqsx"]
|
[ext_resource type="AudioStream" uid="uid://bki17g7j4kqn4" path="res://assets/Audio/PickupSound Mixdown 3.wav" id="8_dwqsx"]
|
||||||
[ext_resource type="Shader" uid="uid://djbvmc8hurccm" path="res://assets/Shaders/speedlines.gdshader" id="10_5hu7c"]
|
[ext_resource type="Shader" uid="uid://djbvmc8hurccm" path="res://assets/Shaders/speedlines.gdshader" id="10_5hu7c"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dyd272r7n2ecd" path="res://assets/Audio/footsteps-shoes-jump-land-beach-sand-SBA-300118001.wav" id="10_tn0pn"]
|
[ext_resource type="AudioStream" uid="uid://dyd272r7n2ecd" path="res://assets/Audio/footsteps-shoes-jump-land-beach-sand-SBA-300118001.wav" id="10_tn0pn"]
|
||||||
@@ -156,6 +157,8 @@ move_transition_speed = 4.0
|
|||||||
script = ExtResource("5_m0ick")
|
script = ExtResource("5_m0ick")
|
||||||
|
|
||||||
[node name="Wall Running" type="Node" parent="States"]
|
[node name="Wall Running" type="Node" parent="States"]
|
||||||
|
script = ExtResource("6_1npgd")
|
||||||
|
move_speed = 20.0
|
||||||
|
|
||||||
[node name="Ground Pound" type="Node" parent="States"]
|
[node name="Ground Pound" type="Node" parent="States"]
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ config_version=5
|
|||||||
|
|
||||||
config/name="First Person Test"
|
config/name="First Person Test"
|
||||||
config/tags=PackedStringArray("fps")
|
config/tags=PackedStringArray("fps")
|
||||||
run/main_scene="uid://cfaydhd6u5bmb"
|
run/main_scene="uid://b55ukxds1s7ih"
|
||||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||||
config/icon="uid://6svuq1l83al5"
|
config/icon="uid://6svuq1l83al5"
|
||||||
|
|
||||||
|
|||||||
@@ -15,3 +15,34 @@ func standard_movement(delta):
|
|||||||
|
|
||||||
func apply_gravity(delta):
|
func apply_gravity(delta):
|
||||||
character.velocity.y -= 9.8 * 1.25 * delta
|
character.velocity.y -= 9.8 * 1.25 * delta
|
||||||
|
|
||||||
|
func enable_wall_rays():
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
character.wall_ray_1.enabled = true
|
||||||
|
else:
|
||||||
|
character.wall_ray_1.enabled = false
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
character.wall_ray_2.enabled = true
|
||||||
|
else:
|
||||||
|
character.wall_ray_2.enabled = false
|
||||||
|
|
||||||
|
func can_wall_run():
|
||||||
|
if character.wall_ray_1.is_colliding() or character.wall_ray_2.is_colliding() or character.wall_ray_3.is_colliding():
|
||||||
|
return true
|
||||||
|
|
||||||
|
func start_wall_running():
|
||||||
|
var running_surface_normal
|
||||||
|
var wall_run_direction
|
||||||
|
if character.wall_ray_1.is_colliding():
|
||||||
|
running_surface_normal = character.wall_ray_1.get_collision_normal()
|
||||||
|
wall_run_direction = running_surface_normal.rotated(Vector3(0,1,0), deg_to_rad(90))
|
||||||
|
elif character.wall_ray_2.is_colliding():
|
||||||
|
running_surface_normal = character.wall_ray_2.get_collision_normal()
|
||||||
|
wall_run_direction = running_surface_normal.rotated(Vector3(0,-1,0), deg_to_rad(90))
|
||||||
|
|
||||||
|
print("SURFACE NORMAL : ", running_surface_normal)
|
||||||
|
|
||||||
|
character.wall_run_direction = wall_run_direction
|
||||||
|
character.wall_run_surface_normal = running_surface_normal
|
||||||
|
Transitioned.emit(self,"wall running")
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ var last_ground_pos
|
|||||||
## Movement
|
## Movement
|
||||||
var input_dir
|
var input_dir
|
||||||
|
|
||||||
|
# Wall Running
|
||||||
|
var wall_run_surface_normal
|
||||||
|
var wall_run_direction
|
||||||
|
|
||||||
## GUNS AND AMMO
|
## GUNS AND AMMO
|
||||||
var gun : Node
|
var gun : Node
|
||||||
var holstered_gun_id : int
|
var holstered_gun_id : int
|
||||||
@@ -433,17 +437,6 @@ func ladder_collide():
|
|||||||
else:
|
else:
|
||||||
gravity = level_control.gamemode.gravity
|
gravity = level_control.gamemode.gravity
|
||||||
|
|
||||||
func 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:
|
func _on_wall_jump_timer_timeout() -> void:
|
||||||
can_wall_jump = true
|
can_wall_jump = true
|
||||||
|
|
||||||
@@ -474,9 +467,6 @@ func grab_moveable(body):
|
|||||||
body.gravity_scale = 0
|
body.gravity_scale = 0
|
||||||
moveable_holder.add_child(body)
|
moveable_holder.add_child(body)
|
||||||
body.global_position = moveable_holder.global_position
|
body.global_position = moveable_holder.global_position
|
||||||
#for i in body.get_children():
|
|
||||||
#if i.get_class() == "CollisionShape3D":
|
|
||||||
#i.collision_layer = true
|
|
||||||
held_item = body
|
held_item = body
|
||||||
|
|
||||||
func hold_item(_delta):
|
func hold_item(_delta):
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ func Physics_Update(delta):
|
|||||||
standard_movement(delta)
|
standard_movement(delta)
|
||||||
apply_gravity(delta)
|
apply_gravity(delta)
|
||||||
|
|
||||||
|
enable_wall_rays()
|
||||||
|
|
||||||
if Input.is_action_just_pressed("jump") and character.jumps_remaining > 0:
|
if Input.is_action_just_pressed("jump") and character.jumps_remaining > 0:
|
||||||
character.jumps_remaining -= 1
|
character.jumps_remaining -= 1
|
||||||
character.velocity.y += character.JUMP_VELOCITY
|
character.velocity.y += character.JUMP_VELOCITY
|
||||||
@@ -23,3 +25,6 @@ func Physics_Update(delta):
|
|||||||
|
|
||||||
if character.is_on_floor():
|
if character.is_on_floor():
|
||||||
Transitioned.emit(self,"on foot")
|
Transitioned.emit(self,"on foot")
|
||||||
|
|
||||||
|
if can_wall_run():
|
||||||
|
start_wall_running()
|
||||||
|
|||||||
21
scripts/player_wall_running.gd
Normal file
21
scripts/player_wall_running.gd
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
extends PlayerState
|
||||||
|
class_name PlayerWallRunning
|
||||||
|
|
||||||
|
func Physics_Update(delta):
|
||||||
|
if character.is_on_floor():
|
||||||
|
Transitioned.emit(self,"on foot")
|
||||||
|
else:
|
||||||
|
wall_run_movement(delta)
|
||||||
|
|
||||||
|
apply_gravity(delta)
|
||||||
|
|
||||||
|
if !can_wall_run():
|
||||||
|
Transitioned.emit(self,"in air")
|
||||||
|
|
||||||
|
func wall_jump():
|
||||||
|
character.velocity += (Vector3(0,1,0) + character.wall_run_surface_normal).normalized() * 10
|
||||||
|
|
||||||
|
func wall_run_movement(delta):
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
character.velocity.x = lerp(character.velocity.x,character.wall_run_direction.x * move_speed,delta * 7)
|
||||||
|
character.velocity.z = lerp(character.velocity.z,character.wall_run_direction.z * move_speed,delta * 7)
|
||||||
1
scripts/player_wall_running.gd.uid
Normal file
1
scripts/player_wall_running.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bgj2bqb5dys41
|
||||||
Reference in New Issue
Block a user