HI I got a little problem. I’m trying to do a boost for my racing game that gives speed when you touch it but if I use an onEnterTrigger the finish line gives a speed boost too. I tries using a tage but it doesnt work so far here is my code for the tag
void OnTriggerEnter()
{
if (transform.tag == “PowerUp”)
{
currentSpeed *= currentSpeed;
}
}
my tag is placed on the collectable but the collectable doesnt give me the spedd boost so I assume I did something wrong with the tage could someone help me?
you can use the
OnTriggerEnter (other : Collider)
and then just check which collider it is colliding with
tyvm ^^ even my teacher didnt know an onTriggeEnter could take a collider lol you have been a great help really thank you
You really don’t need a tag for a trigger/collider. Just:
var moveSpeedIncrease : float;
function OnTriggerEnter( who : Collider )
{
var mover : MovementScript; // Refers to a movement system...
mover = who.GetComponent( MovementScript );
mover.speed += moveSpeedIncrease;
}
Something like that. Unsure of your code’s setup. This works for AIs too.
well the solution of waltermana worked great but ty for the other solution ^^ even if we dont do our code in java its really appreciated ty ^^