Collision just doesn't work!

BlitzMax Forums/MiniB3D Module/Collision just doesn't work!

Hezkore(Posted 2009) [#1]
Right, so I've been trying to figure out why collision won't work in my game...
Basically what happens is that I _sometimes_ glide against objects, but then all of the sudden I just go straight through them, I've tried to figure out what's causing it but I just can't figure it out!
(Though turning the object 45 degrees seem to cause me to glide through almost every time)

I don't have any examples of this, but it's pretty straight forward, just the typical EntityType() and then Collisions() and I move by using MoveEntity() and then I can just walk through the wall.
I haven't been able to reproduce it in any test code and I've tried removing everything in my game that has to do with Entity movements and collision to do, but still no luck in finding the cause...

Anyone had similar problems, any fixes for this?


Yasha(Posted 2009) [#2]
Assuming miniB3D's built-in collision works the same way as real-B3D's collision system does, you can't have dynamic collision. If your objects are both moving, the check will fail; checks are between a moving object, and a static object. So if you're "gliding through" the target at the same time as you rotate it, that's probably the cause.

One way around it might be to port this, if you don't need this functionality often or between many objects. Or you could be more adventurous and replace the collision system altogether with ColDet (which allows more complex collision detection) - I know at least one person here has tried that.


slenkar(Posted 2009) [#3]
If you cant make an example its probably your code,

Are you using resetentity?


Hezkore(Posted 2009) [#4]
No I don't use ResetEntity() anywhere, I am working out an example though.


Hezkore(Posted 2009) [#5]
Found the problem!
Turns out you'll glide through objects at high X, Y, Z positions.
You can set "chv" to 0 and you'll see that the ball no longer glides through the cube.

Now the question is... Is this possible to fix somehow? :o

SuperStrict

Import sidesign.minib3d

Graphics3D 1024, 768, 0, 2, 60
SeedRnd(MilliSecs())

Global chv:Int = 900000 'Crazy high value! (Try setting this to 0)

Global Camera:TCamera = CreateCamera()
CameraRange Camera, 2, 10000
PositionEntity(Camera, 800 + chv, 600 + chv, chv)

Local LIGHT:TLight = CreateLight(1)

Local Cube:TMesh = CreateCube()
PositionEntity(Cube, chv, chv, chv)
ScaleEntity(Cube, 150, 150, 150)
RotateMesh(Cube, 0, 45, 0)
EntityType(Cube, 2)
PointEntity(Camera, Cube)

Local Sphere:TMesh = CreateSphere()
PositionEntity(Sphere, 100 + chv, chv, - 300 + chv)
ScaleEntity(Sphere, 35, 35, 35)
EntityRadius(Sphere, 35, 35)
EntityType(Sphere, 1)

Collisions(1, 2, 2, 2)
While Not AppTerminate()
	Cls()
	MoveEntity(Sphere, 0, 0, 2)
	UpdateWorld()
	RenderWorld()
	Flip()
Wend



ima747(Posted 2009) [#6]
Away from a computer with minib3d installed at the moment, but what if chv is a float instead of an int (900,000 should be less than an int's max but just out of curiosity...) since the positional vars in minib3d are floats...


slenkar(Posted 2009) [#7]
Blitz3D has the same problem, when things are too far away from 0,0,0 things get crazy.