0 votes

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"

Godot version Godot 3.4
in Engine by (28 points)

2 Answers

+3 votes

in part "_process" u need to add Tab after your IFs

        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")

and

    if Player.has_method("_damage"):
    Player._damage()

Good Luck

by (45 points)
0 votes

As DexterFstone said, just do this:

    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")
by (215 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.