The Complete STOS Reference

 pre-release 0.2 Edited By Dr Phibes

STOS 3D #5, collisions

by Matthew Green
 

Today's lesson is all about ways of programming collisions in STOS3-D.

I use two methods of detecting collisions :

  1. Use the TD Zone command that is just like using the zone command in normal STOS.
  2. Or you could use the TD Range command for the detection of collisions.
Any of the two methods above are ok to use. The second one is bestused with a small amount of objects, because it is very easy to use.

We shall tackle the difficult one first.

Setting Zones.

You first have to set the zone, remember that the zone if not square likeit is using the normal STOS command. It is a sphere (e.g. football shape)You can set the zones using a line like :

100 TD SET ZONE n,zone,x,y,z,r

n = the object number
x,y,z = the centre of the zone.(normally the same co-ordinates as the object)
zone = the zone number, 0,1,2,3....up to 20
r = the radius of the sphere(you can find out there radius of an objectwhen you are in the O.M)

To detect weather two zones have hit each there are two ways of doing it :

200 H=TD COLLIDE(n1,n2)

This checks to see if object 1(n1) has hit object 2(n2). if it has then H = n2other wise H = -1

Or you can do this :

200 H=TD COLLIDE(n)

This checks to see if any objects have hit object (n) if they have then H= the number of the object that hit it. Other wise H = -1

Range:

The other method of detection which could work well with your programis if you use the RANGE command. e.g.

100 if td RANGE(n1,n2)<500 then boom : END

This checks to see wether object 1(n1) is less than 500 units away fromobject2(n2). If it is the program ends. But you could have it do anything.

So that is two methods of collision, you should be able to add this to your progams to make them even better.

Remember if you have any problems you can write to me , my address is inthe contax and i will try and answer you questions.

Until next time......