acceleration/deceleration - muss noch in player.gd implementiert werden
This commit is contained in:
@ -23,6 +23,10 @@ window/size/window_width_override=1280
|
||||
window/size/window_height_override=720
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="Sidescroller"
|
||||
|
||||
[input]
|
||||
|
||||
jump={
|
||||
|
||||
18
sidescroller/scripts/playeraccelerationdeceleration.gd
Normal file
18
sidescroller/scripts/playeraccelerationdeceleration.gd
Normal file
@ -0,0 +1,18 @@
|
||||
extends State
|
||||
class_name AccelDecel
|
||||
|
||||
@export var acceleration = 2000
|
||||
@export var deceleration = 1500
|
||||
|
||||
func movement(velocity_x, speed, input_direction, v_mult, v_push, delta):
|
||||
var target_speed = speed * input_direction * v_mult + v_push
|
||||
if input_direction != 0:
|
||||
return move_toward(velocity_x, target_speed, acceleration * delta)
|
||||
return move_toward(velocity_x, 0, deceleration * delta)
|
||||
|
||||
func turnmovement(velocity_x, speed, input_direction, v_mult, v_push, delta, direction_locked, facing_direction):
|
||||
var vx = movement(velocity_x, speed, input_direction, v_mult, v_push, delta)
|
||||
var fd = facing_direction
|
||||
if not direction_locked and input_direction != 0 and sign(input_direction) != facing_direction:
|
||||
fd = sign(input_direction)
|
||||
return [vx, fd]
|
||||
@ -0,0 +1 @@
|
||||
uid://cst40h14xfhjk
|
||||
Reference in New Issue
Block a user