Alice Community

Alice Community (
-   How do I...? (
-   -   tracking the mouse (

shiohigari 06-06-2012 12:16 AM

tracking the mouse
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.

Mr Kidnapper 06-06-2012 09: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.

All times are GMT -5. The time now is 10:11 PM.

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