- Home /
Assign spawned object to SmoothFollow target
Hi All
I'm using the smoothfollow script on my camera in a multiplayer game. It is a racing game, and I'm using RPC calls to make sure all the players have joined before starting the game.
When all the players have joined, I then spawn all the cars so the race can begin. The problem I'm having, is that the camera always keeps following only the one player (it seems like it is always following the last player spawned).
What I would like, is to have the camera follow your own car, instead of following another car.
I've tried adding this code to where the player gets spawned:
var car: Object = Instantiate(playerPrefab, position, transform.rotation);
Camera.main.SendMessage("SetTarget", car);
The SetTarget function is
function SetTarget (t : Transform)
{
target = t;
}
Answer by Herman-Tulleken · Sep 08, 2010 at 11:43 AM
You can simply check whether the car belongs to the player, like this:
if (car.networkView.isMine)
{
Camera.main.SendMessage("SetTarget", car.transform);
}
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
SmoothFollow script issue for multiplayer car game 0 Answers
Multiplayer camera switch issue 0 Answers
Multiplayer Client Missing Reference To Spawn Object 1 Answer