I am trying to access the object I instantiate - basically a prefab car instantiates cars (one after one) …the problem that when try to move one … they all move together … what’s the best way to separate them (and control them one after one)
the game is about parking … the first car appear i choose which line to move to (target = empty-object) , then the second car appears and i choose which line also to move (the problem is here : when i hit the left/right-row all the cars go left and right … i want only the last one to change the line )!!
Any Ideas … Thank You:)
Add
public bool isLockMove=false; to your car control script.
And then add the code below in the Update method of your car control script which must be top of Update method
private void Update(){
if(isLockMove==true){
return;
}
//your car control
}
And then add trigger collider to your target point and then add script. Make all car tags “car”. Your added script to your target point with trigger collider must have this code below
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag==“car”)
{
other.gameObject.GetComponent().isLockMove = true;
}
}