- Home /
Question by
adfol · May 30, 2016 at 07:37 AM ·
c#newbiefirst-person-controllernew
Making player character walk slower when further from centre
I want a basic code or if statement without writing 25 lines of code for every 10 metres or whatever. Here is what I have so far
public float Speed;
void Start ()
{
Speed = 10;
}
void FixedUpdate ()
{
if(transform.position.x >= 15.0f)
{
Speed = 5;
}
else if(transform.position.x <=15.0f)
{
Speed = 10;
}
I don't want to add another code for y if I can save time, since my character doesn't travel in the z it doesn't matter to me.
But is there anyway to say every 10 metres or every 15 metres half the current speed?
Comment
Your answer
Follow this Question
Related Questions
Help with Putting GameObjects into a list. 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers