how to change the smooth follow target object of the main camera ?

when I go into collision with an object that destroys the first target object ?

The question title and actual question make no sense... clarify?

Allow me to translate: SmoothFollow is a Standard Assets script. It has a 'target' variable to specify the object the camera should follow. The script is attached to the main camera. The original target is being destroyed so a new target needs to be set. It actually makes more sense than many questions on here :)

1 Answer

1

In the same block of code that you Destroy the original target that you collide with (I assume this happens in an OnCollisionEnter or OnTriggerEnter function?) get a reference to the smooth follow script and update the target variable. C# example:

SmoothFollow script = Camera.main.GetComponent<SmoothFollow>();
script.target = newTarget.transform;  // newTarget is a reference to the new game object you want to follow