Physics tip

Blitz3D Forums/Blitz3D Programming/Physics tip

JoshK(Posted 2003) [#1]
Previously, I have been calculating entity velocities as the difference between the entity position before UpdateWorld and the position after. This is wrong.

Instead, multiply the normal of the collisions with your velocity to get the new velocity:

If EntityCollided(p\entity,2)
	m=Magnitude(p\velocity[0],p\velocity[1],p\velocity[2])
	For c=1 To CountCollisions(p\entity)
		p\velocity[0]=p\velocity[0]+CollisionNX(p\entity,c)*Abs(p\velocity[0])
		p\velocity[1]=p\velocity[1]+CollisionNY(p\entity,c)*Abs(p\velocity[1])
		p\velocity[2]=p\velocity[2]+CollisionNZ(p\entity,c)*Abs(p\velocity[2])
		Next
	EndIf

I expect this to fix a number of errors I was getting with verlets.


Bot Builder(Posted 2003) [#2]
is this with my verlet code (for the engine)? or are you continuing developing your own code? Right now I'm doing a 'windows update' to get .net support, and I can't really test it. I believe I'm doing somthing similar. I'll post my coll. code tommorow, as it's late(or very very early) here. although it is 19.6mb out of 24 done....


eBusiness(Posted 2003) [#3]
I'm pretty shure it depends on what type of collision you want, should it bounce off like a ball, or should it go along the wall. It depends on the item, and by chance it is somewhere between the two methods. Well Halo's new function is, whatever, mine work good enought.