Collision responses

Blitz3D Forums/Blitz3D Programming/Collision responses

RifRaf(Posted 2003) [#1]
Does anyone know of a simple way to respond to collisions by just using collisionX Y Z , and CollisionNX Y Z?

I hae a craft flying around, when it hits a wall I want it to bounce a bit off of it on the X and Z axis.


Bot Builder(Posted 2003) [#2]
hmmm. well.
[code]
Const bounciness#=1

c=CountCollisions(craft)
For i=1 To c
PositionEntity craft,EntityX(craft,1)+CollisionNX(craft,i)*cvx#,EntityY(craft,1)+CollisionNY(craft,i)*cvy#,EntityZ(craft,1)+CollisionNZ(craft,i)*cvz#,1
Next

;cvx#, cvy#, and cvz# are the velocity of the craft these are not neccessary
;unless you want the bounce velocity To be proportional To the initial velocity.
;you might have To set bounciness To a negative number. Not sure at the moment -To lazy
[code]


Neo Genesis10(Posted 2003) [#3]
Not exactly possible im afraid. In order to use the CollisionXYZ commands you need to set up an entity for collision detection. This also means that the entity will be affected by collisions as well. If the player, for example, collides with a wall then the built-in collision would occur on UpdateWorld (also needed to update the CollisionXYZ values) rather than your own routines.


Ross C(Posted 2003) [#4]
You could do a line pick from the ship, and get the picked normal, and use this.


Warren(Posted 2003) [#5]
Yes, but if you tell the collision system to simply stop the entity, you should be able to then detect the collision and reset it's speed/direction within the same frame.