Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- export var accel = 1
- export var speed = 1000
- export var gravity = 19.6
- var velocity = Vector2()
- var h_velocity = Vector2()
- var movement = Vector2()
- func _physics_process(delta: float) -> void:
- velocity = Input.get_vector("ui_left","ui_right","ui_up","ui_down")
- velocity = velocity.normalized()
- h_velocity = h_velocity.linear_interpolate(velocity * speed,accel * delta)
- movement.x = h_velocity.x
- movement.y = h_velocity.y
- movement = move_and_slide(movement,Vector2.UP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement