Hi i’m trying to boost only one car by clicking on it but wherever i clicked all the cars boost up. Even the clicking position doesnt matter. How can i do it properly?
void Update ()
{
if (Input.GetMouseButtonDown(0)){
IsBoosted=true;
}
if(IsBoosted)
BoostCar();
else
MoveCar();
}
Jeric Miana is right essentially.
Your script is fine, but add some sort of collider. I have had problems with a mesh collider not being recognised, so I recommend another type.
I once had a similar issue with tree instances. Make sure that the cars aren’t instances or controlled by a script that would affect them all, such as being children of a parent that holds the script. What you can do is instantiate them all, and have the prefab that is copied from have your script on it, so that all of the cars do.