Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
tracking the mouse
Junior Member
Status: Offline
Posts: 1
Join Date: Jun 2012
Default tracking the mouse - 06-05-2012, 11:16 PM

I am trying to have a character track the mouse no matter where i put it.

To do this i am going to have the distance from the top and left of the screen saved in variables and then compare them in some sort of function to spit out a number that i can rotate the character by.

I'm thinking i need some sort of arctan function for this but i can't work out how to do it, my maths isnt that great.

If anyone can figure it out or suggest another way that would be great.

The camera is looking top down at the character.
Reply With Quote
Mr Kidnapper
Senior Member
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 06-06-2012, 08:13 PM

If the position of the camera is static in the Z axis (Height), an easy way is that you can use the current mouse's position as a percentage of the window's width and height starting from the center, assuming the character is positioned at the center. You then manually figure out how much distance there is in meters on the XY axis to the edges of the window. There is no fancy trigonometry that you have to do.

This takes a little Jython scripting, however, because there is no Alice function to find the window's width and height. Finding my as well as Arty-FishL's worlds that use mouselock and mouse-based camera rotation should be a first step. You can use WinZip and Notepad++ to view the python files.

From what it sounds like, you want to click a position on the ground and move the character to that position.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.