Advertisement

Where am i?

Started by June 10, 2003 11:19 AM
0 comments, last by Kronos259 21 years, 8 months ago
I have created a room ,added movement and a function to enable lighting inside the room.(By pressing L i can enable/disable lighting).The problem is i want to be able to "turn on the lights" only when i am in a certain area inside my room.Now, no matter where i am i can enable lighting. Any ideas ?
lets say your position in the room is x,y,z
choose a point in the room x2,y2,z2

calculate your distance from that point.
d = sqrt((x-x2)*(x-x2)+(y-y2)*(y-2)+(z-z2)*(z-z2));

Now you can test the distance:

if(d<2) {
turn on lighting
}

This topic is closed to new replies.

Advertisement