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

Talk about making games.

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

Postby bat78 » Fri Jul 20, 2012 12:41 pm

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 ?
Attachments
pic.png
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Jagmaster » Fri Jul 20, 2012 1:44 pm

EDIT:

If you want it to be perfect, use this:

x = view.x+xmouse;

with distance


x = view.x+xmouse+10;
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 2:29 pm

It won't take effect..the view need to be another positioned..
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 2:34 pm

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.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Jagmaster » Fri Jul 20, 2012 2:37 pm

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.
Attachments
Mouse.ged
(1.08 KiB) Downloaded 114 times
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

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

Postby Jagmaster » Fri Jul 20, 2012 2:40 pm

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)
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 2:41 pm

hmm
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 2:44 pm

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.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Jagmaster » Fri Jul 20, 2012 2:55 pm

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
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 3:12 pm

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 (:
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 3:13 pm

Yes that is "Mouse3.ged" i need to take a look
EDIT: Yes i didn't see the last thanks. Your idea looks greate.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Jagmaster » Fri Jul 20, 2012 3:17 pm

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:
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 3:20 pm

np I have a great orientation :lol:
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby bat78 » Fri Jul 20, 2012 3:23 pm

I have 2 more problems for my full different game :)
They are hard to be explained :D
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Hblade » Sat Jul 21, 2012 4:21 pm

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 =)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest