Blitz3D's collision system

Blitz3D Forums/Blitz3D Programming/Blitz3D's collision system

Ken Lynch(Posted 2003) [#1]
I've been experimenting with Blitz's collision detection and I am finding it very limited, the only things I can seem to guarantee are moving-to-static object collisions. I'm trying to work on a project which needs lifts and spinning platforms, which I've got working using a line pick down from the player, but if the player approaches the lift from the side he just goes straight through. Are there any ways of replacing Blitz's collision system with one that is less limited and still remain fast or are there any decent code examples that deal with more complex collisions?


RetroBooster(Posted 2003) [#2]
The blitz collision system is far from limited, use it properly and you can accomplish lifts, springs and moving platforms with ease, just don't think everything will work with 1 command, it's collision detection not magic! ;) Trying things like linepick is going in the right direction. Lemme give you one good hint on character positioning:

Say you have a human model walking around your world and you want him to step up to a small platform if he bumps into it from the side, then you just do a linepick with a radius about the size of his feet and start that linepick at the height of your models knees while ending it a few centimeters under your model, then you use that pick every frame to position your character on the surface that is underneath it (if there is any that is) if you run into a platform now and it's under kneeheight your character will step on to it.

That's my example for now, I'm sure you'll run into more complex problem, but thrust me they can be solved. ;)


jhocking(Posted 2003) [#3]
In many situations the built-in collision detection is best as a sort of first pass. In your example of moving lifts set the player to sphere-to-polygon collisions against the lift objects so that he won't go through (eg. when approaching from the side) but then use a linepick for more accurate information to do stuff like having the player move with the platform.

Similarly, when you want super accurate polygon-polygon collision detection for everything you can often use the built-in collision detection for a rough first pass and then use MeshesIntersect with anything detected as colliding after the first pass.


Neochrome(Posted 2003) [#4]
I have this sussed. I did use a Line Pick..

lets see if my code is of help

;########################### LIFTS ########################################

			If EnvData\itemTag = "liftopen"	; do to the movers
				MoveEntity LocalPlayer,0,5.5,0
				If EnvData\itemTag = "liftopen" Then PositionEntity LocalPlayer,EntityX(LocalPlayer),EntityY(EnvData\model)+12,EntityZ(LocalPlayer)
				EnvData\itemTag = "lm1"
				OnMoverTime# = 2
				EnvData\Angle=0
			ElseIf EnvData\itemTag = "lm1" Then
				m# = (getitemdata(EnvData\itemID%,"maxopen"))
				my# = EnvData\ly# + m#
				If my# > EntityY(EnvData\model) Then
					EnvData\Angle# = Qlimit(EnvData\Angle#+.01,0,1)
					TranslateEntity EnvData\model,0,EnvData\Angle,0
				Else
					EnvData\itemTag = "liftclose"
					EnvData\itemTimer = GetItemData(EnvData\itemID%,"opentime")
				End If
				UnderMe = LinePick(EntityX(LocalPlayer,1),EntityY(LocalPlayer,1),EntityZ(LocalPlayer,1),0,-14,0,.1)
				UpdateWorld()
				If UnderMe = EnvData\model
					PositionEntity LocalPlayer,EntityX(LocalPlayer),EntityY(EnvData\model)+14,EntityZ(LocalPlayer)
					resetplayer()
				EndIf

			ElseIf EnvData\itemTag = "liftclose"
				EnvData\itemTimer# = EnvData\itemTimer# - GameSeconds#
				If EnvData\itemTimer<0 Then	EnvData\itemtag="liftclosing":EnvData\Angle=0
			ElseIf EnvData\itemTag = "liftclosing"

				If EntityY(EnvData\model) > EnvData\ly# Then
					EnvData\Angle# = Qlimit(EnvData\Angle#-.01,-1,1)
					TranslateEntity EnvData\model,0,EnvData\Angle,0
				Else
					EnvData\itemTag = "liftclosed"
				End If
				
			ElseIf EnvData\itemTag = "liftclosed"
				EnvData\itemTag = ""
				PositionEntity EnvData\Model,EnvData\lx#,EnvData\ly#,EnvData\lz#
			End If



as you can see, it isn't simple.
Basically when the playing find the lift, it will use Linepick to know whats happening.

Its by far not the best way to do it. BUT it works for me VERY well! he will walk on the plat form and is also able to leap off the moving object too!