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!
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!
Assuming you have just one SmoothLookAt script in the scene:
var someTarget : Transform; // Or whatever your target transform is
var script = FindObjectOfType(SmoothLookAt);
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