Question by
PhilGrealey · Nov 06, 2015 at 01:42 PM ·
wheelcolliderspeed upmotortorque
How do I increase MotorTorque when entering a trigger collider (C#)
Hi,
I'm making a buggy racing game in Unity and am having some trouble with the wheel collider physics.
I want speed boosts in my game and when the player drives over one their speed will increase significantly for a few seconds. Currently the code I have does increase the motorTorque and maxSpeed figures in the inspector panel however the buggy in game doesn't seem to get any faster. I have no Idea what I'm doing wrong.
I have included the code where my speedBoost takes affect.
void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "SpeedBoost")
{
maxSpeed = maxSpeed * speedBoost;
maxTorque += 20000;
StartCoroutine ("RevertSpeed");
}
if (other.transform.tag == "Weapon")
{
playerHit.Play();
takenDamage = true;
TakeDamage ();
}
}
IEnumerator RevertSpeed()
{
yield return new WaitForSeconds(3);
maxTorque = 5000;
}
Can anybody shed some light on this?
Regards
Comment