0 votes

I'm trying to learn the online multiplayer in Godot, it was everything going okay until I try to put animations. I don't know what's happening, I'm using the same code for animations that I found in all multiplayer projects but just don't work
Here's my code:

func _process(_delta):
    var horizontal = - int(Input.is_action_pressed("left")) + int(Input.is_action_pressed("right"))
    var vertical = - int(Input.is_action_pressed("up")) + int(Input.is_action_pressed("down"))
    velocity = Vector2(horizontal, vertical).normalized() * speed
    if velocity != Vector2():
    if is_network_master():
        motion = move_and_slide(velocity)
    rpc_unreliable("_set_position", global_position)

# ANIMATIONS ------------------------
    if velocity.length() > 0:
        newAnim = "Run"
        newAnim = "Idle"

    if currentAnim != newAnim:
        currentAnim = newAnim

Here's the animation in game

The animations are playing in both players, I've tried to put the animation states inside the "if isnetworkmaster" and don't work, I've also tried to use an script on a node attached to the player and use the "get_parent()" but does the same thing.

I have also another question that if anyone could answer, it will be cool
- If I want to have a local multiplayer (same pc) and an online multiplayer, should I have two types of script for player?

in Engine by (16 points)

Please log in or register to answer this question.

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.