I am making a game and I want to make two others follow the one I drive. If you can in the form of a v or triangle and if not in a row. I have done a navmesh. What I want to do is drive all 3 at the same time and have the other players follow
Asked
Active
Viewed 28 times
1 Answers
0
If your game is in 3d just find target positions feg. like that:
Vector3 targetPosition1 = playerTransform.position + Quaternion.AngleAxis(angle,Vector3.up) * (-playerTransform.forward) * distance;
Vector3 targetPosition2 = playerTransform.position + Quaternion.AngleAxis(-angle,Vector3.up) * (-playerTransform.forward) * distance;

Paweł Łęgowski
- 716
- 4
- 7
-
I don't understand, would there be handling the two characters in the same script? – Helen Mar 09 '20 at 23:22
-
You wanted two other characters to follow player in V shape. Thats how to calculate their target positions for navmeshagents, paste it wherever you need, you have not pasted any code so I can't do anything more, and it solves your question, just need minimum effort on your side now. – Paweł Łęgowski Mar 09 '20 at 23:24
-
I think I understand, then player Transform would be the position I want them to follow, right? There are two gameobjects, so I suppose that a target correlates to each one, right? – Helen Mar 09 '20 at 23:30
-
Yes, playerTransform is the transform you want to follow, angle is half of the angle between them, and distance is distance from player to followers. But it will only work if you rotate your player in OX during movement, you can use rigidbody.velocity.normalized or feg. yourPlayerScript.direction if you are not rotating player/not using rigidbody etc. playerTransform.forward should be the direction your player is moving – Paweł Łęgowski Mar 09 '20 at 23:32
-
I swear it's the last thing I ask you xD What type of variable is angle? I want to put about 20 degrees – Helen Mar 09 '20 at 23:39
-
It's degrees as float. – Paweł Łęgowski Mar 09 '20 at 23:41