Hey Guys, been trying to figure out this problem for a while and its become way to confusing for my newly developed JavaScript brain to handle.
Ok so my game is a 2.5D platformer where the player collects “Burgers” for health and is then hurt by salads, he also grows fatter and skinnier as he eats the burgers.
When the “player” collides with burgers the burger variable increases by one and everything is fine, when the player run into the enemy everything is fine, UNTIL the player stands still and let the enemy collide with the player, then NOTHING happens to the variables.
//heres my code:------------------------------------------
var BurgerPositive : int = 1;
var BurgerNegative : int = -1;
function Start(){
BurgersGui.Burgers = 1;
}
function Update(){
//bellow is code that states, if you loose all the burgers, it executes the code
if(BurgersGui.Burgers <1){
Application.LoadLevel(0);
}
}
function OnTriggerEnter(collision : Collider){
if(collision.gameObject.tag == (“Collectable”)){
//Applies the health by sending the information to the BurgerGui.js.
BurgersGui.Burgers +=BurgerPositive;
//plays audio clip assigned to this object
audio.Play();
//Makes the player get fatter
transform.localScale += Vector3(0.1,0.1,0.1);
}
//Below is script that causes damage and reduces one variable
if(collision.gameObject.tag == ("enemy")){
//Applies the damage by sending the data to the HeartsGui.js.
BurgersGui.Burgers +=BurgerNegative;
transform.localScale += Vector3(-0.1,-0.1,-0.1);
}
}
Does anyone know what the problem might be?