feat: changed wallrun physics
This commit is contained in:
parent
0e69b5a8c4
commit
896cde7619
1 changed files with 11 additions and 4 deletions
|
|
@ -306,12 +306,14 @@ script/source = "extends PlayerAction
|
|||
@export var gravity_scale : float
|
||||
@export var max_upward_velocity : float
|
||||
@export var drag : float
|
||||
@export var run_speed : float
|
||||
@export var blend_in_time : float
|
||||
@export var min_ground_speed : float
|
||||
@export var jump_normal_force : float
|
||||
@export var jump_input_force : float
|
||||
@export var jump_vertical_force : float
|
||||
@export var min_run_time : float
|
||||
@export var jump_force_ground_input_ratio : float
|
||||
|
||||
var run_time : float = 0.0
|
||||
|
||||
|
|
@ -322,15 +324,18 @@ func _enter() -> int:
|
|||
if body.is_on_wall_only() and input_velocity_dot > 0.01 and ground_velocity.length() >= min_ground_speed and flat_velocity.length() > -body.velocity.y * 4.0:
|
||||
if Input.is_action_just_pressed(\"jump\") and run_time > min_run_time:
|
||||
var wall_flat := Vector3(body.get_wall_normal().x, 0, body.get_wall_normal().z)
|
||||
body.velocity = wall_flat * jump_normal_force + (ground_velocity + blackboard.get_world_move_input()).normalized() * jump_input_force * ground_velocity.length()
|
||||
body.velocity = wall_flat * jump_normal_force + (ground_velocity * jump_force_ground_input_ratio + blackboard.get_world_move_input()).normalized() * jump_input_force * ground_velocity.length()
|
||||
body.velocity.y = jump_vertical_force
|
||||
blackboard.character.look_at(blackboard.character.global_position + Vector3(body.velocity.x, 0, body.velocity.z))
|
||||
blackboard.anim.set(\"parameters/AirTime/blend_amount\", 0.0)
|
||||
else:
|
||||
if run_time <= 0:
|
||||
body.velocity.y = max_upward_velocity
|
||||
body.velocity = ground_velocity.normalized() * lerp(run_speed, 0.0, run_time * drag) + Vector3(0, body.velocity.y, 0)
|
||||
run_time += get_process_delta_time()
|
||||
body.velocity *= 1 - drag
|
||||
#body.velocity *= 1 - drag
|
||||
body.velocity += body.get_gravity() * get_process_delta_time() * gravity_scale
|
||||
body.velocity.y = min(max_upward_velocity, body.velocity.y)
|
||||
#body.velocity.y = min(max_upward_velocity, body.velocity.y)
|
||||
blackboard.character.look_at(blackboard.character.global_position + body.velocity)
|
||||
blackboard.anim.set(\"parameters/WallAction/blend_amount\", 1.0)
|
||||
blackboard.anim.property_move_toward(\"parameters/Wall/blend_amount\", 1.0, get_process_delta_time() * blend_in_time)
|
||||
|
|
@ -518,13 +523,15 @@ process_mode = 1
|
|||
script = SubResource("GDScript_3rfka")
|
||||
gravity_scale = 0.169
|
||||
max_upward_velocity = 2.0
|
||||
drag = 0.002
|
||||
drag = 0.001
|
||||
run_speed = 7.0
|
||||
blend_in_time = 50.0
|
||||
min_ground_speed = 5.0
|
||||
jump_normal_force = 4.0
|
||||
jump_input_force = 1.3
|
||||
jump_vertical_force = 4.0
|
||||
min_run_time = 0.05
|
||||
jump_force_ground_input_ratio = 5.0
|
||||
|
||||
[node name="WallGrip" type="PlayerAction" parent="PlayerBehaviourTree/BehaviourRepeater/ActionSelector" unique_id=85039173]
|
||||
script = SubResource("GDScript_nmc1l")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue