PDA

View Full Version : How to keep objects within an object


koollilme_7
09-10-2008, 01:08 AM
I have a temple as an object, and within the temple are 4 circle shapes,which move random distances and in random directions. My problem is that i cant manage to retain the circles witin the temple and they keep going out. How do i make them stay within? I know i should check weather they are within a dist of 1m to the temple,but if they are, which direction should they then move in?
Thanks,:D

Digimath
09-10-2008, 06:26 AM
What if you set up an array of positions within the temple and then randomly picked one for the move-to destination for a circle?

DrJim
09-10-2008, 01:24 PM
While I like the idea of randomly moving between preset points, especially if the structure is complicated :) - I suspect the original question came about because the circles moved outside the temple before the distance test was made.

You should always be very careful to identify the point at which a test is made, remembering that, unless you use a "do together" block, commands are always executed sequentially.

I've attached a small example. Note that if you set the distance moved for each step in the loop to too large a value, the sphere will always "escape."