Page 1 of 3

HELP: How to make an object to follow mouse with distance :?

PostPosted: Fri Jul 20, 2012 12:41 pm
by bat78
Hello guys,
I was wondering ..can one actor follow mouse with distance between them ?
First think that i take on mind was: "xmouse=player.x-10;" it is with decent syntax but it doesen't work. Ideas ?

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 1:44 pm
by Jagmaster
EDIT:

If you want it to be perfect, use this:

x = view.x+xmouse;

with distance


x = view.x+xmouse+10;

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:29 pm
by bat78
It won't take effect..the view need to be another positioned..

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:34 pm
by bat78
And with: "x = view.x+xmouse+10; y = view.y+ymouse+10;"
That can't work with distance..x is assigned to view.x but view need to have movement x + mouse movement x.
It is absolute wrong.

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:37 pm
by Jagmaster
The view is in a random position, Offset of 100:

Edit: I had the code in the mouse following actor btw,

Is this what you wanted? If not, lemme know.

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:40 pm
by Jagmaster
Just an explanation, if the actor is assigned to xmouse only, and say, your xmouse is 30, the actor will stay on 30, and will leave the screen. By adding view.x, you make the actor stick to the view first, and then stick to the mouse. (with offset)

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:41 pm
by bat78
hmm

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:44 pm
by bat78
i see but that don't work on me cause if i possition and with "y"
the actor stay on horizontal distance
I want to make x&y to stay an actor on xscreen&yscreen 50:50
but if i just put ur code with x&y the actor follow mouse on down/right side.

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 2:55 pm
by Jagmaster
You just copy the code for the vertical distance then?

Is your actor parented to another actor? I don't see why this won't work. :|
Mouse2.ged
(1.65 KiB) Downloaded 112 times


Edit:
is this what you mean?

Just remove +100?
Mouse3.ged
Is this it?
(1.65 KiB) Downloaded 116 times

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 3:12 pm
by bat78
It work but..see The actor's position is horizontal from the mouse.
I want the position to be "next to the mouse" like my picture (:

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 3:13 pm
by bat78
Yes that is "Mouse3.ged" i need to take a look
EDIT: Yes i didn't see the last thanks. Your idea looks greate.

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 3:17 pm
by Jagmaster
Glad it worked. If you need anything else explained lemme know. :)

Edit: lawl, I forgot to delete the comments on the second line, sorry. :lol:

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 3:20 pm
by bat78
np I have a great orientation :lol:

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Fri Jul 20, 2012 3:23 pm
by bat78
I have 2 more problems for my full different game :)
They are hard to be explained :D

Re: HELP: How to make an object to follow mouse with distanc

PostPosted: Sat Jul 21, 2012 4:21 pm
by Hblade
I love using this method for shooters:

Code: Select all
angle=direction(xscreen, yscreen, xmouse, ymouse);
directional_velocity=distance(xscreen, yscreen, xmouse, ymouse)/6;


its awesome =)