Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 24th Dec 2013 23:07
Hi community!
Does anyone know how can i program an object to follow the mouse cursor?
I managed to write something but it always centers(the object)



Alex Matei CEO
www.alexmatei.com
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 25th Dec 2013 06:43


Coding is My Kung Fu!
And My Kung Fu is better than Yours!
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 26th Dec 2013 19:32
mousemovex/y/z only gets the number of pixels the mouse position has changed by since the last time you checked. So in your code, if the user isn't moving the mouse the object will always be at 0,0,0. If the user moves the mouse, the object might twitch a little bit but it will return to 0 immediately if they stop because mousemovex/y will be 0 again.

Additionally, mousemovez actually uses the mouse wheel - so in a way, it's not directly related to the other two like you think it might be.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 27th Dec 2013 01:48
Thanks all for the responses! It really helped me. But btw of mousemove as scrolling, does anyone know how can change the speed of the camera when scrolling up and down?

Thank you again, very helpful community out here!

Alex Matei CEO
www.alexmatei.com
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 29th Dec 2013 01:01
To add to BMacZero's post, this is an example of how to use the pick object and pick vector commands, it's not as all that straight forward. I don't think it's exactly what you want but it should help (I think I did this for someone else).



As for changing the speed of scrolling, add a multiplier to speed up or slow down the movement.



As BMacZero said, mousemovez() is the scroll wheel and isn't linked to the movement of the mouse in the same way as mousemovex() and mousemovey() are.

Login to post a reply

Server time is: 2026-07-07 03:46:42
Your offset time is: 2026-07-07 03:46:42