Hey guys,
I’ve been looking at other scripts and I swear this should work but it doesn’t:
var target_ball : Rigidbody;
static var game_state : int = 2;
function Awake()
{
DontDestroyOnLoad (transform.gameObject);
}
function OnGUI()
{
switch(game_state)
{
case 2: // SET THROW
if(!gameObject.Find("Ball"))
{
var target = Instantiate(target_ball, Vector3(10, 5.2, 3.75), Quaternion.identity);
target.name = "Ball";
GameObject.Find("Main Camera").GetComponent("SmoothLookAt").target = target;
}
}
}
The camera has SmoothLookAt.js with var target : Transform;
The error reads: BCE0019: ‘target’ is not a member of ‘UnityEngine.Component’.
How do I change the target of the camera from this script?