Evening all,
I’m putting together an autoscrolling platformer, well trying to anyway… I have a pick up that slows the player down and I’m currently trying to add a pick up that counteracts the effects. I thought the best way to do this (with my limited coding knowledge), would be to use the same script over and reverse the content, or try to. However when the player runs into the speed up trigger it slows him down further. Here’s my (working) slow down script -
public float SlowDownPercentage = 0.5f;
public bool hasSlowedPlayer = false;
void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "Player" !hasSlowedPlayer)
{
collision.collider.GetComponent<PlayerMove>().speed *= SlowDownPercentage;
hasSlowedPlayer = true;
And here’s what I’ve tested to reverse the effects -
public float SpeedUpRate = 0.5f;
public bool hasSpedUp = false;
void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "Player" !hasSpedUp)
{
collision.collider.GetComponent<PlayerMove>().speed *= SpeedUpRate;
hasSpedUp = true;
I have also tried this with ‘is trigger’ enabled -
public float SpeedUp = 0.5f;
public bool hasSpedPlayer = false;
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player" !hasSpedPlayer)
{
other.GetComponent<PlayerMove>().speed *= SpeedUp;
hasSpedPlayer = true;
I’m pretty new to coding and the big scary world of Unity, so I’m trying to keep it simple as possible… Something I can understand really. It’s worth noting, both scripts I have tried work to slow the player down more, instead of speeding up. And ‘Has Sped Player’ in inspector changes to true once player has passed through. However with OnTriggerEnter script the trigger does not disappear as it should. Any suggestions how I can speed my player back up? Thanks in advance ![]()