Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- onready var animatedSprite = $AnimatedSprite3D
- var isAttacking = false
- var movement = Vector3(0, 0, 0)
- var speed = 5
- var Direction = "Left"
- export (int) var damage := 10
- var AttackPoints = 3
- var velocity = Vector3.ZERO
- func _physics_process(delta):
- velocity = Vector3.ZERO
- if Input.is_action_pressed("ui_right"):
- velocity.x += 1
- if Input.is_action_pressed("ui_left"):
- velocity.x -= 1
- if Input.is_action_pressed("ui_down"):
- velocity.z += 1
- if Input.is_action_pressed("ui_up"):
- velocity.z -= 1
- if Input.is_action_just_pressed("attack") && AttackPoints == 3:
- isAttacking == true
- $AnimatedSprite3D.play("Attack_1")
- AttackPoints = AttackPoints - 1
- elif Input.is_action_just_pressed("attack") && AttackPoints == 2:
- $AnimatedSprite3D.play("Attack_2")
- AttackPoints = AttackPoints - 1
- elif Input.is_action_just_pressed("attack") && AttackPoints == 1:
- $AnimatedSprite3D.play("Attack_3")
- AttackPoints = AttackPoints - 1
- var motion = movement.normalized() * speed
- movement = move_and_slide(velocity * speed)
- func _on_AnimatedSprite3D_animation_finished():
- if $AnimatedSprite3D.animation == "Attack_1" || $AnimatedSprite3D.animation == "Attack_2":
- $AnimatedSprite3D.play("idle")
- elif $AnimatedSprite3D.animation == "Attack_3":
- $AnimatedSprite3D.play("idle")
- AttackPoints = 3
- func _on_AttackResetTimer_timeout():
- AttackPoints = 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement