Alice Community How to keep objects on screen?

 How to keep objects on screen?
 zwx650 Junior Member   Status: Offline Posts: 2 Join Date: Feb 2012 How to keep objects on screen? - 02-16-2012, 01:52 AM Hi, I am new to the forum. I tried to search for a similar thread, but couldn't find anything: What should I do to find out if an object has moved to the edge of the screen and is about to be invisible, and then reposition the object to the center of the screen? Thanks in advice for any helps! zwx
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 02-16-2012, 02:43 AM You need some math for that. First you need to find out the field of view angle of the camera. I don't know this either, but a good estimate is just by sticking an object at the edge at a fair distance away, You then use the arctan2 function on this object. Your first parameter for the arctan function is the object distance to the left of the camera, and your second parameter is the object distance in front of the camera. What do you get? I don't know. At any rate, the result should be more or less the same as long as you keep the object more or less at the edge of the camera. Then you make a hardcoded (preset) number variable consisting of the result of the arctan function. Congrats. you found the field of view angle. Now you need to make sure that whenever your objects reach this edge (field of view angle), it teleports to the center of the screen. For this, you make an if/else function. One thing you need to take note of is that you must also do the arctan thing on every object you intend on teleporting to the center of the screen. You should also save it as a number variable. So, if the arctan of the object is greater than positive FoV angle or greater than the negative FoV angle (The FoV, just with a negative sign), it does some method to move the object to the center. This method is kind to you. You can do it simply by getting the distance to the left of the camera and having the object move that (negative) distance.
 Many thanks!
 zwx650 Junior Member   Status: Offline Posts: 2 Join Date: Feb 2012 Many thanks! - 02-16-2012, 12:28 PM That's quite some computation involved Hopefully I will find time to give it a try and report back.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge