![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Dudedude123 |
I had built this code
extends KinematicBody3D
signal health_updated(health)
onready var animation = $SomeGuy/AnimationtionPlayer
export (float) var max_health
onready var health = max_health
func _set_position(pos):
global_transform.origin = pos
# When the character dies, we fade the UI
enum STATES {ALIVE, DEAD}
var state = STATES.ALIVE
func setStateIdle():
animation.play("PlayerIdle",0.1)
func setStateAttack():
animation.play("BodyCross",0.1)
$AudioStreamPlayer3D.play()
func _process():
if Input.is_action_just_pressed("Left"):
animation.play("FightWalkBackwards")
if Input.is_action_just_pressed("Right"):
animation.play("FightWalk")
if Input.is_action_just_pressed("Up"):
animation.play("FightWalkRight")
if Input.is_action_just_pressed("Down"):
animation.play("FightWalkLeft")
if Input.is_action_just_pressed("Punch"):
setStateAttack()
if Player.has_method("_damage"):
Player._damage()
if _is_network_master():
rpc_unreliable("set_position", Global_transform.origin)
func take_damage(count):
if state == STATES.DEAD:
return
health -= count
if health <= 0:
health = 0
state = STATES.DEAD
emit_signal("")
$AnimationPlayer.play("take_hit")
emit_signal("health_changed", health)
func _on_AnimationPlayer_animation_finished( name ):
if state != STATES.DEAD:
return
if name != "take_hit":
return
$AnimationPlayer.play("die")
func _on_Hitbox_body_entered(body):
if body.has_method(""):
body.take_damage()
I keep getting these errors :
Parse Block: Expected an indented block after “if”