0 votes

Someone know why this code doesn't work?:

remote func _damaged(direction):
    print("test")
    StateMachine.travel("Damaged")
    velocity = direction * 200
    velocity = Player.move_and_slide(velocity)
func _on_HitArea_body_entered(body):
    if is_network_master():
        rpc_id(int(body.name), "_damaged", hit_direction)

I got "test" printed on the right player, but neither StateMachine nor velocity work. Does someone know what's happening?

I tried get_parent() instead of Player, but it didn't help either.
Also I tried using rsetid("velocity", hitdirection * 200), but it didn't work too

What I try to achieve is to move one player via a network, when he got hit by another player

Edit:
Player is reference to get_parent()
StateMachine is reference to get_node("../AnimationTree").get("parameters/playback")

Edit2: I found out that if I print get_parent() in func _damaged() then it shows not the player who should receive signal, but the player who sends rpc. For example when id 23112 sends rpc_id(1, "_damaged"), in func _damaged() in print(get_parent()) there is printed 23112. I'm really confused right now why it happens because I got a "test" printed on the client with id 1.

in Engine by (12 points)

try remotesync

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 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 webmaster@godotengine.org with your username.