Creating a Collision

The Collisions command is used in Blitz3D to define how objects will collide with one another. There are five different things that you must specify when creating collisions:

  • Source Type. The source type tells Blitz3D which object it should watch for that might collide into something else. Typically, this is the player or players in your game. In the example we are going to use below, we will create a sphere that will collide with a cone. In this example, the sphere would be the source type.

  • Destination Type. This is the object that is being collided into. In the example, the cone acting as our object to smash into will be the destination type.

Figure 11.1 illustrates the difference between a Source type and a Destination type.

Figure 11.1. The difference between a Source and a Destination type.


  • Entity Radius. Imagine a really skinny cat trying to walk into the open entrance of your house. The cat could probably do it with no problem at all. Now imagine an 800-pound elephant trying to get through the same door—it’d probably get stuck. In Blitz3D, you have to define how “fat” or “skinny” your objects are so that the program knows whether or not a collision should occur when two objects get close to one another. You have to define this by setting an entity radius for each source object. Keep in mind that creating a large or small entity radius doesn’t actually change the shape or size of an object; it just tells Blitz3D how close or far objects need to be to one another for a collision to be registered. Figures 11.2 and 11.3 illustrate how the radius of an object works.

Figure 11.2. In this example, a collision wouldn’t occur because the radii of the two objects don’t collide.


Figure 11.3. In this example, a collision occurs because the radii of the two objects collide.


  • Method. This controls the detection method for the collisions. Your choices are:

ellipsoid-to-ellipsoid = 1
ellipsoid-to-polygon = 2
ellipsoid-to-box = 3

  • Response. This tells the program how you want an object you are moving to react when it hits another object. You can have it stop, slide sideways, or slide upwards. Different numbers indicate the type of response you want as follows:

Stop = 1
Slide Sideways = 2
Slide Upwards = 3

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.171.153