shaky mouse controlled actor

Non-platform specific questions.

shaky mouse controlled actor

Postby EasyViber » Fri Apr 28, 2006 11:17 pm

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?
EasyViber
 
Posts: 21
Joined: Fri Feb 24, 2006 4:43 pm
Location: Zagreb, Croatia
Score: 0 Give a positive score

Postby DilloDude » Fri Apr 28, 2006 11:57 pm

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby frodo » Mon May 01, 2006 3:54 pm

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.
User avatar
frodo
 
Posts: 127
Joined: Tue Mar 21, 2006 6:53 pm
Location: universe
Score: 2 Give a positive score

Postby frodo » Mon May 01, 2006 4:00 pm

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.
User avatar
frodo
 
Posts: 127
Joined: Tue Mar 21, 2006 6:53 pm
Location: universe
Score: 2 Give a positive score

Postby EasyViber » Wed May 17, 2006 7:37 pm

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;
EasyViber
 
Posts: 21
Joined: Fri Feb 24, 2006 4:43 pm
Location: Zagreb, Croatia
Score: 0 Give a positive score

Postby Troodon » Thu May 18, 2006 12:36 pm

Simpler way is to make a "fake mouse" actor. And when collision with fakemouse
Code: Select all
xvelocity=0;
yvelocity=0;

:wink:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest