Scene Objects are acting as players.
Options
Hi, I'm developing a car combat game, and there are players, and defense towers on each team.
Each player has a photonview, and so do the towers (towers aren't spawned though, they are already in the scene).
I deal damage through an RPC, and if the hit enemy dies, it adds to the other players score using PhotonMessageInfo (info.sender.AddScore(1);).
That works fine, the problem is, when a tower kills an enemy, it adds score to the player that got killed. So if I get killed by the tower, it adds 1 to my score, but if another player gets killed by the same tower, it counts one point for them.
How should I proceed to stop this from happening? I tried getting info.photonview.name, but it returns the player object, and not the tower.
Each player has a photonview, and so do the towers (towers aren't spawned though, they are already in the scene).
I deal damage through an RPC, and if the hit enemy dies, it adds to the other players score using PhotonMessageInfo (info.sender.AddScore(1);).
That works fine, the problem is, when a tower kills an enemy, it adds score to the player that got killed. So if I get killed by the tower, it adds 1 to my score, but if another player gets killed by the same tower, it counts one point for them.
How should I proceed to stop this from happening? I tried getting info.photonview.name, but it returns the player object, and not the tower.
0
Comments
-
I do not quite understand what you mean.
There is a type of games - tower defense
Here is a sketch of realization -
The player builds a tower -PhotonNetwork.Instantiate
The tower shoots at enemies(Sends RPC damage to all - minus hp)
The tower is the owner of the player. It sends the player points. (photonView.owner.AddScore
) Through condition if(sender.isLocal
)
example[PunRPC] void damage(PhotonMessageInfo info) { hp -= 10; if (hp <= 0 && info.sender.IsLocal) photonView.owner.AddScore(1); }
0