I’ve created a project containing three cars and carselection.js attached to the main camera in the scene “Selection” then another scene “Level 1”. Now question is that should I create three separate cameras to follow selected objects or there is a way to follow single camera to follow selected player in “Level 1” scene?
Well, there are many ways to reach what you want. Every car has it’s own scene, if you want your Camera to follow the specific car you can just add in your script the field:
public GameObject target;
and then drag it in the Inspector. In each scene, this property will be pointing on another Gameobject
if you don’t know how to write Camera script, you can find some.
yes you can use single camera.
Just make a method to change the target for camera. For Example:
In Camera Movement script, write this method (it is in c#, you can make in js).
void Update () {
if (yourTrasnform) {
//follow it
}
}
public void changeTransform(Transform trans)
{
projectile = trans;
}
And When you are selecting your car, call this method as you can see it’s a public method.
So first make a object for your camera movement script then you given script:
Example: yourCamMovementSCript.changeTransform(this.transform)
It’s done. Hope it will help you.