- Home /
how do i make teams for a rts game
I'm making a rts game and ran into this problem of how am i going to set up teams. I can't use tags or the name of the game object so im not sure how i'm going to do this.
So as you can see I got team 1 and team 2. If I spawned a tank and I am on team 2 I need it to be set to team 2 automaticly. I also need a way to see if my raycast is hitting team 1 or team 2.
i will give likes to all helpful comments or ones asking what i mean Plz do not put a answer in if you do not have a full answer
Answer by BeardOfFury · Nov 11, 2013 at 03:54 AM
I'd suggest using layers personally, you can set a game object's layer in code:
gameObject.layer = TEAM1;
Then you can use layers to check against the different teams from raycasts:
RaycastHit hit;
Physics.Raycast(origin, Vector3.forward, out hit);
if(hit.collider.gameObject.layer == TEAM2)
{
//DO STUFF
}
Hope this helps
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do i have AI objects have teams and attack when in range 3 Answers
Distribute terrain in zones 3 Answers
Need help converting C# to Javascript! 1 Answer
Converting from javascript to c# 1 Answer