Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- var velocity = Vector3(0,0,0)
- const SPEED = 2
- onready var animatedSprite = $AnimatedSprite3D
- func _physics_process(delta):
- if Input.is_action_pressed("ui_right") and Input.is_action_pressed("ui_left"):
- velocity.x = 0
- elif Input.is_action_pressed("ui_right"):
- velocity.x = SPEED
- animatedSprite.animation = "Walk"
- elif Input.is_action_pressed("ui_left"):
- velocity.x = -SPEED
- animatedSprite.animation = "Walk"
- else:
- velocity.x = lerp(velocity.x,0,0.1)
- animatedSprite.animation = "Idle"
- if Input.is_action_pressed("ui_up") and Input.is_action_pressed("ui_down"):
- velocity.z = 0
- elif Input.is_action_pressed("ui_up"):
- velocity.z = -SPEED
- animatedSprite.animation = "Walk"
- elif Input.is_action_pressed("ui_down"):
- velocity.z = SPEED
- animatedSprite.animation = "Walk"
- else:
- velocity.z = lerp(velocity.z,0,0.1)
- if velocity.x > 0:
- animatedSprite.flip_h = false
- elif velocity.x < 0:
- animatedSprite.flip_h = true
- move_and_slide(velocity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement