Collision Radius

You’ll notice from the last section that the sphere couldn’t get close to the cone. You can specify how close to or far from an object you can get by specifying a radius using the EntityRadius command. You specify the radius for the individual objects. Let’s continue with the same program we were using in the last section. If you’ve closed it, open the file called demo11-03.bb. We simply changed the previous program a tiny bit. The change between demo11-02.bb and demo11-03.bb is highlighted in bold below.

; Creating a sphere
sphere=CreateSphere()
ScaleEntity sphere, 0.5,0.5,0.5
PositionEntity sphere, -3,0,5
EntityType sphere,type_player
EntityRadius sphere, 0.2

Go ahead and run the program now, and you’ll see that you can get a lot closer to the object because you’ve entered a radius less than 1 (see Figure 11.6).

Figure 11.6. You can now get much closer to the cone in demo11-03.bb. In fact, you can get halfway through the cone before the collision occurs.


If you entered a radius greater than 1, you wouldn’t be able to get as close to the cone.

Note: Now You Try

Practice entering different radius values between 0 and 1 and then greater than 1 to see how it affects how close your sphere can get to the cone.


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

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