Alice Community Compass

 Compass
arty-fishL
Senior Member

Status: Offline
Posts: 1,878
Join Date: Mar 2008
Location: In the corner of your eye
Compass - 05-24-2010, 02:32 PM

I dont mean to copy Dameria's idea of a compass, I just wanted to post this for anybody who wants to know how to make one easily.
I didnt understand Dameria's way, so I thought up my own way of doing the compass. This is completely not based on Dameria's version, but he helped my work out what was wrong with arcsin, so thanks.

This is a compass which points north as you turn or move with the arrow keys. You can also make it point towards an objective.

----

To do this in your own world place three dummies at the camera, move two of them forward equal distances and one backward the same distance. The distance doesnt matter, just as long as all the distances are equal, I recommend 20 metres.
Label one of the front ones north and the other front one you and label the back one south. Make you vehicled to the camera then copy all the code I have in my example world.

----

This is how it works:
This is a diagram of the points

you could be facing any way, this is just an example.

The points are even distances from the camera, so a circle can be drawn due to the equal radii.

From this we can add in known measurements, like the radius and distance from you to north.

Then we can draw a line from the centre to the middle of the black chord above. This will form a right angled triangle.

This allows us to use a simple form of trigonometry to calculate the angle in the right angled triangle; this can be doubled to get the overall angle, and therefore the final bearing.

To calculate x when we know the radius (r) and the chord length (c) we can do x=arcsin(c/2/r). Then we can calculate double x to get the bearing.

Then to get the turn percentage that Alice uses you can do bearing divided by 360, this will give a value between 0 and 1.

edit: version 1.1 - now should not really have a problem with it getting stuck at north and should not face a little bit off any more as it resets and calculates its position again every 200 calculations (which is enough), and its not really noticeable that much.
Attached Files
 compass angle v1.1.a2w (351.3 KB, 29 views)

█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
█░░▓░░░░░░░▓░░░░░░░░░░░▓▓░░▓░░░░░░▓░░░▓░░░░█
█░▓░▓░▓▓▓░▓▓▓░▓░▓░░░░░░▓▒▒░░▒░░▓▓░▓▓▓░▓▒░░░█
█░▓▓▓▒▓▒▒▒░▓▒▒▓▓▓▒▓▓▓░▓▓▓░░▓░░░▓▒▒▓▒▓▒▓▒░░░█
█░▓▒▓▒▓▒░░░▓▓░░▒▓▒░▒▒▒░▓▒▒░▓▓░▓▓▒░▓▒▓▒▓▒░░░█
█░▓▒▓▒░▒░░░░▒▒▓▓▓▒░░░░▓▓▒░░░▒▒░▒▒░░▒░▒▓▓▓░░█
█░░▒░▒░░░░░░░░░▒▒▒░░░░░▒▒░░░░░░░░░░░░░░▒▒▒░█
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█

I have mostly moved on from Alice, but may still respond to messages if important [¬º-°]¬

Last edited by arty-fishL; 05-25-2010 at 05:04 PM. Reason: new version

 jediaction Senior Member     Status: Offline Posts: 5,064 Join Date: Jul 2009 Location: Bel Air, Maryland 05-31-2010, 05:26 PM Its so simpel yet complicated. Nice job Website: www.salokingames.com FaceBook: www.facebook.com/SalokinGames
amatuer
Guest

Status:
Posts: n/a
08-10-2011, 06:58 PM

Attached Files
 fpsmummies.a2w (1,010.7 KB, 0 views)

room14
Senior Member

Status: Offline
Posts: 549
Join Date: Nov 2009
Location: Auckland New Zealand
08-11-2011, 03:37 AM

um Does it do the same thing with a lot less hassle?
Attached Files
 compass.a2w (172.6 KB, 3 views)

:D

 sfunk Senior Member     Status: Offline Posts: 1,112 Join Date: Mar 2011 Location: I don't know 08-11-2011, 03:38 PM that seems pretty complicated, I made a compass on my very first game which was very simple, it was just a arrow vehicled to a cube which the cube would be what turn to face the object I wanted it to and then the arrow would point towards it (I can't remember why I vehicled the arrow to the box) I think the arrow would turn to face with the wrong part of the object If you are stuck on a project, check out the tutorials I made here at this link: http://alice.org/community/showthread.php?p=36778#post36778 There are lots of tutorials on it so far, including some youtube videos, check it out Or.. Go to my youtube channel to check out my alice 2.2 tutorials I have there.. http://www.youtube.com/user/sfunk1992?feature=mhsn

 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     Alice Player and VR General Discussion     Questions and Comments     The Lounge