I have a timer script which increases the speed of an object after a second has gone by. My shape behavior script calls this script and applies it to itself so that anytime another shape spawns it doesn’t start at the lowest speed but from where the timer left off. Problem is, anytime a shape appears, it simply remains frozen in place. I’m really having trouble figuring this out, and would very much appreciate the help!
There is an Instantiate script applied to three “spawner” objects in the hierarchy which calls the shape prefabs to instantiate and point towards the player. This is working just fine. There is a Timer script which is applied to the groundplane and tracks time and increases the speed variable as time goes on, and finally there is a Shape Behavior script which is applied to the shape prefabs, calls on both the Instantiate and Timer scripts and enables them to get destroyed when clicked on and should enable them to move towards the player at an accelerated rate (which isn’t working). I’ll attach the Timer and ShapeBehavior scripts.
Timer
#pragma strict
public var time : float;
public var speed : float;
function Start()
{
speed = 0.1;
}
function Update()
{
time += Time.deltaTime;
if (time > 1)
{
speed += 0.01;
time = 0;
}
}
ShapeBehavior
#pragma strict
var Player : GameObject;
var sound : AudioSource;
var TimeManager : GameObject;
var ShapeSpeed : float;
function Start()
{
ShapeSpeed = TimeManager.GetComponent(Timer).speed;
}
function Update()
{
transform.Translate(0, 0, ShapeSpeed);
Debug.Log(ShapeSpeed);
}
function OnMouseDown()
{
sound.audio.Play();
Player.GetComponent(Player_Script).score = Player.GetComponent(Player_Script).score + 15;
yield WaitForSeconds(.11);
Destroy(gameObject);
}