collision normal for physics
Blitz3D Forums/Blitz3D Programming/collision normal for physics
| ||
Hi, Is there a way to make an object bounce backwards at the angle of the normal it just collided with? e.g. if it hits a surface head-on it would move directly backwards, Is there also a way of making the colliding object spin in the right direction as if it had hit the normal in real life- e.g. if the colliding object is facing up (entitypitch compared to normal=+5) at the normal make it spin downwards (entitypitch=-5 compared to pitch of normal) |
| ||
http://www.blitzbasic.com/Community/posts.php?topic=34953 ; If the entity collided with the level, make it bounce. If Entity_Hit > 0 ; Calculate bounce: ; Get the normal of the surface which the entity collided with. Nx# = CollisionNX(ballpos, 1) Ny# = CollisionNY(ballpos, 1) Nz# = CollisionNZ(ballpos, 1) ; Compute the dot product of the entity's motion vector and the normal of the surface collided with. VdotN# = Vx#*Nx# + Vy#*Ny# + Vz#*Nz# ; Calculate the normal force. NFx# = -2.0 * Nx# * VdotN# NFy# = -2.0 * Ny# * VdotN# NFz# = -2.0 * Nz# * VdotN# ; Add the normal force to the direction vector. Vx# = Vx# + NFx# Vy# = Vy# + NFy# Vz# = Vz# + NFz# This might help a little |
| ||
so Vx is the velocity of the object right? thanks for the help |
| ||
Yes...For the X# component. Take some time and read the information in the link that I gave you... SSwift, gave me some really good information... Have you looked at Tokamak Physics engine yet? Regards, Eric |
| ||
yeah but this will be a lot simpler to implement, the physics isnt the focus of the game - thanks |