Where am i?
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 ?
June 10, 2003 11:38 AM
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
}
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement