- Home /
Changing camera target of CarSmoothFollow ( Js to c#)
Hi
I am trying to toggle between three characters and want to change the target of CarSmoothFollow to smoothly transition from character to character as they are each enabled. I have looked at the link---- http://answers.unity3d.com/questions/265193/how-to-change-what-prefab-the-camera-is-following.html---- but there is a problem in that CarSmoothFollow is in C# and I am cant script in c.
I tried doing it like this:
var Astron_1 : Transform;
if( blah blah blah){
var AstroCam=(GameObject.Find("MainCamera1").GetComponent("CarSmoothFollow") as CarSmoothFollow);
AstroCam.target=Astron_1;
}
CarSmoothFollow is in Standard Assets but it doesnt work.
Any idea how I can get it to work ?
I'm lost - can you help me understand what doesn't work?
Hi it keep saying NullReferenceException: Object reference not set to an instance of an object
So either there isn't an object called $$anonymous$$ainCamera1 or it doesn't have a CarSmoothFollow script attached to it.
Your answer
Follow this Question
Related Questions
how can i make the main cam smooth follow a new prefab that i add after the game start . 5 Answers
How to change Target of camera from Standard Assets 1 Answer
Changing Target Depending On Car Selected 1 Answer
Move camera upon button press 0 Answers
Ease in transform.LookAt() - keep other target within camera boundaries 1 Answer