Page 1 of 1

car speed/mouse

PostPosted: Thu Jun 07, 2007 2:02 am
by Oman
hello,
I was wondering if there was a code to make my car (player actor) move faster depending on how far away it is from the crosshair. Like if my crosshair was 30 pixels away from the car the car would be moving somewhere around 3 velocity, but if the crosshair was 120 pixels away from the car then the car would be moving somewhere around 7 velocity.

I am using this code now, but it doesn't do exactly what i want.

angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = 8;

By the way the crosshair follows the mouse...

any help is appreciated :D

Re: car speed/mouse

PostPosted: Thu Jun 07, 2007 2:28 am
by Sgt. Sparky
Oman wrote:hello,
I was wondering if there was a code to make my car (player actor) move faster depending on how far away it is from the crosshair. Like if my crosshair was 30 pixels away from the car the car would be moving somewhere around 3 velocity, but if the crosshair was 120 pixels away from the car then the car would be moving somewhere around 7 velocity.

I am using this code now, but it doesn't do exactly what i want.

angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = 8;

By the way the crosshair follows the mouse...

any help is appreciated :D

you need to use,
Code: Select all
angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = distance(x, y, crosshair.x, crosshair.y) / 12;
:D

PostPosted: Thu Jun 07, 2007 2:51 am
by Oman
I knew it was simple like that...

Thanks a ton sparky :D

PostPosted: Thu Jun 07, 2007 2:54 am
by Sgt. Sparky
you are Welcome, any time! :D