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"
else:
newAnim = "Idle"
if currentAnim != newAnim:
currentAnim = newAnim
animPlayer.play(currentAnim)
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?