Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- onready var AnimSprite = $AnimatedSprite3D
- var velocity = Vector3(0, 0, 0)
- var speed = 70
- var isAttacking = false
- var isJumping = false
- var gravity = -20
- var jump_impulse = 300
- var input_vector = Vector3.ZERO
- onready var AttackArea = $AttackArea
- export (int) var damage := 10
- var canMove = false
- var timer = null
- var crouch_delay = 0.5
- var isCrouch = true
- var current_animation
- func _process(delta):
- if $AnimatedSprite3D.animation == "punch" and $AnimatedSprite3D.frame !=2:
- return
- input_vector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
- input_vector.z = Input.get_action_strength("move_up") - Input.get_action_strength("move_down")
- input_vector = input_vector.normalized()
- if input_vector != Vector3.ZERO && canMove:
- velocity.x = input_vector.x * speed
- velocity.z = input_vector.z * -speed
- AnimSprite.play("walk")
- else:
- velocity.x = 0
- velocity.z = 0
- AnimSprite.play("idle")
- if Input.is_action_just_pressed("punch") : #and isWalking:
- $AnimatedSprite3D.play("punch")
- if velocity.x > 0:
- AnimSprite.flip_h = false
- scale.x = 29
- elif velocity.x < 0:
- AnimSprite.flip_h = false
- scale.x = -29
- velocity = move_and_slide(velocity)
- return velocity.normalized()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement