Loading prefab to scene

Hi All,

I am trying to change the target of the Camera - SmoothFollow script right after loading the scene, below is the portion of code from the SmoothFollow script:

var TruckName : String;
var go : GameObject;

function LateUpdate () 
    // Early out if we don't have a target
    if (!target) {
        TruckName = ES2.Load.<String>( "TRUCKSELECT.TXT?tag=Truck" );
        go = Resources.Load( TruckName );
        target = go.transform;

The game object loaded was not shown in the scene although the camera view did change its view/position.

Do I need to declare the game object variable as public or create an empty game object at the scene level first and then use it in the script ?

Many thanks for the kind help and assistance.

Best regards,

As ExTheSea said, Resources.LOad only return the prefab. You need to instantiate it. As it’s probably not going to change, you should load it at start and only once.

By the way, such values for a translate are a bit odd. You may have to re-think your logic there. Maybe use an other transform to setup the position properly, add its reference in that script and use its position instead ?