Advertisement
Lakamfo

inertia

Mar 28th, 2022
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends KinematicBody2D
  2.  
  3. export var accel = 1
  4. export var speed = 1000
  5. export var gravity = 19.6
  6.  
  7. var velocity = Vector2()
  8. var h_velocity = Vector2()
  9. var movement = Vector2()
  10.  
  11.  
  12. func _physics_process(delta: float) -> void:
  13.     velocity = Input.get_vector("ui_left","ui_right","ui_up","ui_down")
  14.     velocity = velocity.normalized()
  15.    
  16.     h_velocity = h_velocity.linear_interpolate(velocity * speed,accel * delta)
  17.     movement.x = h_velocity.x
  18.     movement.y = h_velocity.y
  19.    
  20.     movement = move_and_slide(movement,Vector2.UP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement