Physics and collisions

Blitz3D Forums/Blitz3D Programming/Physics and collisions

RiverRatt(Posted 2005) [#1]
I am working on a hover craft type game using Tokamak. Got everything working pretty smooth but one problem I can't seam to solve is the camera and rigid body it rides on, often go through walls.

I have tried adding blitz collisions around the camera and the rigid body object, and though blitz detects the collisions it does not seam to help (but there is a small improvement).

I have also tried changing toksim_advance but that does not seam to help either.

All movement of rigid body camera and RB object are done using censors, AI, and is done using tokamak move functions (mostly tokrb_applyimpulse2).

So does anyone have any ideas what this could be? Do you think I would see an improvement by increasing the density ie pollycount of the level mesh? Or would it help to increase the size of the bank holding the mesh data?


WolRon(Posted 2005) [#2]
You do know that Blitz doesn't handle collisions well when both objects are moving, right? You can only compute one at a time.


RiverRatt(Posted 2005) [#3]
I know that. The only collisions going on right now are between the camera setup and the level.
I only put basic blitz collisions in to see if it would help when tokamak collisions fail. It has helped a little, but still at just the right angle and speed it shoots through the walls of the level.

I should explain the camera setup a little better...

I have a platform (box; obj) set up with a rigid body (rb) and that has 4 bottom tokamak censors and two top tokamak censors. The bottom censors keep the platform floating like a hover craft, by applying a minute force to the rb, the top censors are to keep the player upright, and apply extra downward force if the player hits the ceiling. The camera is not attached to the obj but is positioned with it each frame like so.

;UPDATE PLAYER AND CAMERA NORMALLY
PositionEntity obj,TOKRB_GetX(rb),TOKRB_GetY(rb),TOKRB_GetZ(rb) 
RotateEntity obj,TOKRB_GetPitch#(rb),TOKRB_GetYaw#(rb),TOKRB_GetRoll#(rb),True
PositionEntity camera,EntityX#(obj),EntityY#(obj,True)+2,EntityZ#(obj)
RotateEntity camera,EntityPitch#(obj)+campitch#,EntityYaw#(obj),EntityRoll#(obj)



This is actually done twice each loop.


Bot Builder(Posted 2005) [#4]
try jacking up your tokomak tick subdivisions.


RiverRatt(Posted 2005) [#5]
Bot Builder: Can you please be more specific? I have tried increasing TOKSIM_Advance(1.5/FPS,2.0) to TOKSIM_Advance(1.5/FPS,15.0) but it has no efect ecept slowing everything down, but collisions still fail.

This is the tweening system I am using, so what do you mean "jacking up your tokomak tick subdivisions"?
Const FPS=120

period=1500/FPS
time=MilliSecs()-period

;in main loop

Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)

	For k=1 To ticks
		time=time+period
		If k=ticks Then CaptureWorld

		TOKSIM_Advance(1.5/FPS,2.0)
 ;game stuff

            next




Vorderman(Posted 2005) [#6]
Apparently you can get different results by calling the TOKSIM_Advance function more than once per loop, so try lowering the step value from 1.5 to 0.75 (or possibly 1.0) and calling the function twice -

TOKSIM_Advance( 0.75 / FPS , 2.0 )
TOKSIM_Advance( 0.75 / FPS , 2.0 )


Danny(Posted 2005) [#7]
Perhaps a silly comment but is your camera really going TROUGH the wall or does it STICK through the wall? You might have the 'near range' of your cameraRange(near,far) set too big?!


RiverRatt(Posted 2005) [#8]
Danny; No, that wasn't it. I have to apologize to all, it turned out a to be a stupid mistake on my part. I can't remember where I read it but I am sure somewhere in the docs it said that entities must not be to small. I had the controlling rigid body scaled at 1.5, .2 , 1.5. .2 is just too small. Tokamak could not detect the collisions correctly. Also since I was re positioning the camera each loop the blitz collisions were not picking it up because I was simply re positioning it in the middle of a wall or floor. I will have too rewrite my game. Let this be a lesson to me.