Search Unity

using the 'Smooth Look At' camera script?

Discussion in 'Scripting' started by techbinge, Dec 13, 2007.

  1. techbinge

    techbinge

    Joined:
    Jul 22, 2006
    Posts:
    88
    I'd like to use this script based on an event, rather than happening right away when the level is loaded. Is there a simple way to fire off an event, or a way to call this script and pass it a target as an argument?

    Thanks in advance!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Assuming you have just one SmoothLookAt script in the scene:

    Code (csharp):
    1. var someTarget : Transform;  // Or whatever your target transform is
    2. var script = FindObjectOfType(SmoothLookAt);
    3. script.target = someTarget;
    If there's more than one script of that type, FindObjectOfType returns the first one. So you'd probably want to use another way to reference the script in that case.

    --Eric