Apologies for the confusing title, I just had no clue what to put for the title…
Anyways, I have been trying to make a multiplayer Manhunt tag(Hide and go seek tag) type game as a hobby lately and have gotten most of the components working but, I want to make it so that if the red team(“It”) tags a blue player they respawn as a red player but Im not to sure how I would implement this yet?.. Also, if have it be so that only the red has the ability to tag not all the players as that would defeat the purpose of the game and having people who are “It”… Any suggestions/help would be greatly appreciated!
Thanks,
so you want to make sure the tag detection is running on the blue character as that will make everything easier. Essentially the blue character gets notified that they have been tagged. for example lets assume you use collision detection to set it, although you could use raycast or any other method of choice.
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.CompareTag("RedPlayer"))
{
RespawnAsRed();
}
}
void RespawnAsRed()
{
//set position...
transform.position = mySpawnPointLocation;
//set color or team... im not sure how you already implement this, but this is an example
gameObject.GetComponent<Material>().SetColor("red", Color.red);
}
Now you will have to implement and RPC call with Photon to update the new change for everyone. Essentially put the “RespawnAsRed” as an RPC.targetAll instead of calling the function normally.
You may also want to keep a Boolean that says “isTagged” to keep that you could use later for many implementations like a speed boost only for tagged people, For Example ;).
something like this:
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.CompareTag("RedPlayer"))
{
;
photonView.RPC("RespawnAsRed", RpcTarget.All);
}
}
[PunRPC]
void RespawnAsRed()
{
//set position...
transform.position = mySpawnPointLocation;
//set color or team... im not sure how you already implement this, but this is an example
gameObject.GetComponent<Material>().SetColor("red", Color.red);
}
Thank you very much for your help with this! That was very useful, and easy to understand! Thanks again! Oh yeah and sorry for bothering you a second time but for the teams I’m not sure how I would implement this and even I were to I don’t know if it would affect this code… But since it’s sort of like a game like manhunt how would I randomize the teams. Say, randomly pick 2 people to be “it” or red and the rest to be blue. If you can help, great! And if not, also fine too! Thanks in advance and sorry for bothering you if I have…