[bb] No Reponse Collisions by Ken Lynch [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : No Reponse Collisions
Author : Ken Lynch
Posted : 1+ years ago

Description : This is a small example of how I've used the existing collision system to force a 'no response'. I've used a pivot to parent the object and use the pivot collisions when I want sliding/stop collisions and the actual object if I want to go through the object.

This is useful for collectable items that you don't want to affect your movement.


Code :
Code (blitzbasic) Select
Graphics3D 800,600

light% = CreateLight()
camera% = CreateCamera()

pivot% = CreatePivot()
EntityType pivot, 1
EntityRadius pivot, 0.1

sphere% = CreateSphere()
ScaleEntity sphere, 0.1, 0.1, 0.1
EntityRadius sphere, 0.1
EntityType sphere, 2
EntityParent sphere, pivot

PositionEntity camera, 0, 2, -2
PointEntity camera, pivot

For i = 0 To 5

cube = CreateCube()
EntityType cube, 3
PositionEntity cube, Rnd(-2, 2), 0, Rnd(-2, 2)
ScaleEntity cube, 0.2, 0.2, 0.2

Next

For i = 0 To 5

ball = CreateCylinder()
EntityType ball, 4
PositionEntity ball, Rnd(-2, 2), 0, Rnd(-2, 2)
ScaleEntity ball, 0.2, 0.2, 0.2

Next

Collisions 2, 3, 2, 2
Collisions 1, 4, 2, 2

Repeat

If KeyDown(200) Then TranslateEntity pivot, 0, 0, 0.1
If KeyDown(208) Then TranslateEntity pivot, 0, 0, -0.1
If KeyDown(203) Then TranslateEntity pivot, -0.1, 0, 0
If KeyDown(205) Then TranslateEntity pivot, 0.1, 0, 0

UpdateWorld

PositionEntity sphere, 0, 0, 0

cyl_col% = cyl_col + CountCollisions(pivot)
cube_col% = cube_col + CountCollisions(sphere)

ResetEntity sphere

RenderWorld

Text 0, 0, "Cylinder Collisions: " + cyl_col
Text 0, 16, "Cube Collisions: " + cube_col

Flip

Until KeyHit(1)


Comments :


_PJ_(Posted 1+ years ago)

 Won't the pivots eventually be offset from the meshes after numerous collisons, though?Nevermind... I saw this:
PositionEntity sphere,0,0,0
Still, if a collision causes a stop or slide, the pivot will be affected, then the mesh would be moved, in effect, the same as if the collision was checked on the mesh? [/i]