Can't smoothfollow my mesh?

I am a newbie on a learning curve....

I have dropped a mesh, 3rd person controller, and smoothfollow into a prefab.

I instantiate the prefab gameobject and attempt to assign the target for smoothfollow.

    PlayerShip = Instantiate (PlayerShip, Vector3 (0,0,0), Quaternion.identity);

    Debug.Log("goin for it!");
    var sf : SmoothFollow = Camera.main.GetComponent(SmoothFollow);
    if (sf)
    {
        sf.target = PlayerShip.transform;
        Debug.Log("got it!");
    }

I see "goin for it!" but I don't see "got it!" in the console window.

When I run it it my playership mesh moves to the press of the arrow keys but the camera is not attached to the playership.

Am I doing this correctly?

1 Answer

1

This may seem fairly obvious, but make sure the 'main camera' game object actually has a SmoothFollow component attached.

Also, it looks like you're assigning the value returned by Instantiate() back to PlayerShip. It might not make any difference in this case (e.g. if the code in question is only executed once), but usually you would assign the return value to a different variable and leave the reference to the source object unchanged.

never assume anything with a newbie. I had the smoothfollow on the plane. doh! Thanks!

–