Hello,
Im trying to learn more about RPCs and I have a question about a problem I have.
I have two players and one enemy npc, the npc should lookAt the player that is shooting on it.
For testing, I simulate the shooting with hitting key I (Player 1 is shooting) and key O (Player 2 is shooting).
When I shoot on the enemy using the server, the rotation of the enemy is showing up correctly on the client.
But when I try it on the client, the server doesnt show the new rotation of the enemy and I dont understand why.
Here is my code:
var direction_player1 : Transform;
var direction_player2 : Transform;
function Update ()
{
networkView.RPC ("target_player", RPCMode.AllBuffered);
}
@RPC
function target_player()
{
if(Input.GetKey(KeyCode.I))
{
transform.LookAt(direction_player1);
}
if(Input.GetKey(KeyCode.O))
{
transform.LookAt(direction_player2);
}
}
The script is attached to the enemy gameobject and also has a networkview applied.
Im using Reliable Delta Compressed and its observing the gameobject.
I tried to observe the script file instead of the gameobject, but this didnt help.
Also I tried it with a OnSerializeNetworkView function, but the behaviour was exactly the same.
Can anyone please tell me what Im doing wrong? I cant get it to work.
Im very thankfull for any kind of help/hints.
cheers