Scenario (in JS):
ballLaunch gameobject has 1) a script to instantiate a new prefab, 2) the new var prefab. Heiarchy has teh ballLaunch item and a target - in this case a simple plane with the "Finish" tag selected in the inspector.
For some reason, the prefab is not instantiating. I've gotten it to work at times, but overall it is not functioning and all my poking hasn't advanced it any.
Here is the script attached to the ballLaunch gameobject, in addition to the prefab (below):
var ball : GameObject;
private var currentBall : GameObject;
private var currentTarget : GameObject;
function Update () {
currentTarget = GameObject.FindWithTag ("Finish");
if (currentTarget == true && currentBall == false)
ballSpawn ();
}
function ballSpawn () {
var currentPosition : Vector3 = transform.position;
currentBall = Instantiate (ball, currentPosition, Quaternion.identity);
currentBall.tag = "Player";
}
And here is the ballMoving script attached to the ball. The prefab placed in the above slot is made up of only the sphere and this script:
var ballSpeed : float = 2.0;
var ballDamping : float = 1.0;
private var currentTarget : GameObject;
function Update () {
ballMoving ();
}
function ballMoving () {
ballLookat = currentTarget.transform.position - transform.position;
rotation = Quaternion.LookRotation (ballLookat);
transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * ballDamping);
transform.Translate (Vector3.forward * Time.deltaTime * ballSpeed);
}
Sorry for the additional tracking additions as this is a smaller part to a larger project I am working on. Any help would be greatly appreciated.
Happy New Year to everyone!
Jonathan