Advertisement
chris33556

updated script 26_06-2022

Jun 26th, 2022
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. var velocity = Vector3(0,0,0)
  4. const SPEED = 2
  5.  
  6. onready var animatedSprite = $AnimatedSprite3D
  7.  
  8. func _physics_process(delta):
  9.  
  10. if Input.is_action_pressed("ui_right") and Input.is_action_pressed("ui_left"):
  11. velocity.x = 0
  12. elif Input.is_action_pressed("ui_right"):
  13. velocity.x = SPEED
  14. animatedSprite.animation = "Walk"
  15. elif Input.is_action_pressed("ui_left"):
  16. velocity.x = -SPEED
  17. animatedSprite.animation = "Walk"
  18. #else:
  19. #velocity.x = lerp(velocity.x,0,0.1)
  20. #animatedSprite.animation = "Idle"
  21.  
  22. elif Input.is_action_pressed("ui_up") and Input.is_action_pressed("ui_down"):
  23. velocity.z = 0
  24. elif Input.is_action_pressed("ui_up"):
  25. velocity.z = -SPEED
  26. animatedSprite.animation = "Walk"
  27. elif Input.is_action_pressed("ui_down"):
  28. velocity.z = SPEED
  29. animatedSprite.animation = "Walk"
  30.  
  31. else:
  32. velocity.x = lerp(velocity.x,0,0.2)
  33. velocity.z = lerp(velocity.z,0,0.2)
  34. animatedSprite.animation = "Idle"
  35.  
  36.  
  37. #velocity = velocity.normalized() * SPEED
  38.  
  39.  
  40. if velocity.x > 0:
  41. animatedSprite.flip_h = false
  42. elif velocity.x < 0:
  43. animatedSprite.flip_h = true
  44.  
  45.  
  46.  
  47.  
  48. velocity = move_and_slide(velocity)
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement