Getting proper rebound...
Blitz3D Forums/Blitz3D Programming/Getting proper rebound...
| ||
Ok, when I'm trying to do some simple, quasi-physics, my main problem comes from getting the correct rebound angle from collisions. To explain, if I use collision normals to align a projectile to a collision, I get this result:![]() What I want to do is have a proper rebound angle, like this: ![]() But I'm honestly not sure how to get the results in a way that would be proper regardless of where the impact takes place. Does anyone have any ideas how to quickly and easily do this? To those who have played Unreal/Unreal Tournament, look at it like this: Razorjack/Ripper disks bouncing off walls. |
| ||
Try this ...For C = 1 To CountCollisions( Entity ) Nx# = CollisionNX( Entity, C ) Ny# = CollisionNY( Entity, C ) Nz# = CollisionNZ( Entity, C ) VdotN# = Vx * Nx + Vy * Ny + Vz * Nz NFx# = -2.0 * Nx * VdotN NFy# = -2.0 * Ny * VdotN NFz# = -2.0 * Nz * VdotN Vx = Vx + Nfx Vy = Vy + Nfy Vz = Vz + Nfz Next AlignToVector Entity, Vx, Vy , Vz , 3, 1 Where Vx, Vy and Vz are your velocity vector. Remember to make them floats. Stevie |
| ||
Thanks! Will try that out ASAP. |