How do I add a speed modifier to my player?


I was wondering if anyone can add a speed modifier to my script. I am trying to make it so my player follows the mouse around, but I don’t want it to be right on the mouse. So, I need a way to modify the player’s speed.

void FixedUpdate ()
      Vector3 temp = Input.mousePosition;
      temp.z = 10f;
      this.transform.position = Camera.main.ScreenToWorldPoint(temp);

-Many Thanks.

P.S. Tell me why your code works, so I am able to learn.

Since you are so eager to learn, I am only going to leave you a link to a function in the scripting reference :wink:

The example code on that page should be plenty to help you!
Good luck!


P.S. Leave a comment if you can’t get it to work and I’ll help you, I just think it’s more fun for you this way.