Speed pickup

Alright, in my game i want speed boosters that will accelerate my First Person Controler. The logical script i think of is: If Firstpersoncontroler.touches boost then Firstpersoncontroler.speed = 15;

So yeah, i’m not very good at coding yet but i would like to figure this out. Thanks!

Hello Camando,

first of all your variable speed should be public(static). The solution I use with pickups is:

  1. make the pickup item trigger
  2. make sure your player has a tag
  3. code time(not something hard)
  4. apply the script to the pickup

What is use is:
`function OnTriggerEnter(hit : Collider){

//are you hit?

if (hit.gameObject.tag == “insert your tag here”){

   //get the speed var in your other script(I will call it FPC now)
     FPC.Speed = 15;

}

`

This is only when you want the speed to be 15 if you hit if you want to add speed, you have to replace FPC.Speed = 15; to:

//add speed (I will use 5)
FPC.Speed += 5;