I am having trouble increasing speed based on score. I think I know roughly what the formula is but the code I try doesn’t work.
var speed : int;
var manager : Manager_Script;
var hit : boolean = false;
function Start () {
manager = GameObject.FindGameObjectWithTag("Manager").GetComponent(Manager_Script);
}
function Update () {
transform.Translate(Vector3(0,(-1) * speed * Time.deltaTime,0));
}
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.tag == "Player"){
speed = speed * player.playerScore
Destroy(gameObject);
manager.playerScore +=10;
manager.cowsSaved ++;
hit = true;
}
if(collision.gameObject.tag == "Ground"){
Destroy(gameObject);
manager.playerLives --;
}
}
I believe that his problem is that OnCollisionEnter is not being called.
– Fornoreason1000