Page 1 of 1

shaky mouse controlled actor

PostPosted: Fri Apr 28, 2006 11:17 pm
by EasyViber
I'm trying to control actor with mouse. It worked fine when I used Follow Mouse action. But now I wanted to get some friction, so that actor moves smoother and with slower acceleration. It works fine when I move mouse, but when I don't move mouse actor starts to shake.

here's simple code I use

Code: Select all
udaljenost = distance(igraac.x, igraac.y, xmouse, ymouse)/15;
MoveTo("igraac", 0, 0, udaljenost, "Mouse Position");


what am I doing wrong?

PostPosted: Fri Apr 28, 2006 11:57 pm
by DilloDude
I think because it is already on top of the mouse, it jerks because it is still trying to move there. So you could add an 'if' to determine if distance is greater than 10, move to mouse.

PostPosted: Mon May 01, 2006 3:54 pm
by frodo
make an invisible actor that follows the mouse.
in your actor that you want towards the mouse draw actor-script editor:

angle=direction(x,y,invisibleactor.x,invisibleactor.y);
directional_velocity=40;

then collision on any side of invisible actor, script editor:

directional_velocity=0;

that should work.

PostPosted: Mon May 01, 2006 4:00 pm
by frodo
a few more things :

in the collision, make it repeat while actor is coliding:"yes".
the invisible actor needs to be made invisible by the visibility state action.
the more the directional_velocity, the more the actor will look like it's following the mouse.

PostPosted: Wed May 17, 2006 7:37 pm
by EasyViber
thnx frodo... your code worked, but player would stop immediately after colliding with invisible actor... so I aded distance variable to make smoother moving... this works fine:

Code: Select all
speed = distance(player.x, player.y, invisibleactor.x,invisibleactor.y)/30;
angle = direction(x,y,invisibleactor.x,invisibleactor.y);
directional_velocity=speed;

PostPosted: Thu May 18, 2006 12:36 pm
by Troodon
Simpler way is to make a "fake mouse" actor. And when collision with fakemouse
Code: Select all
xvelocity=0;
yvelocity=0;

:wink: