Grenade bounces off player incorrectly
by Will Sanders · in Torque Game Engine · 10/05/2002 (9:17 am) · 4 replies
In the Projectile.cc code, when the projectile isn't set to explode, it bounces off of objects until its timer expires. It bounces off walls fine. At least, it looks real/accurate enough. However, whenever it bounces off a player, it always, ALWAYS, bounces back as if it hit a wall at a perfect 90-degree angle. It doesn't matter where you throw it from or where it hits, the projectile always bounces right back as opposed to off at an angle.
Why is this?
Why is this?
#2
Unfortunately, when it DOES hit the player model, no matter where, it always bounces right back at me.
Any clue?
10/05/2002 (10:23 am)
Actually, I have the bounding box lines drawn out so I can see them and the projectile doesn't bounce off of it. It actually does a good job of detecting when it is colliding with the player model. I can easily get the projectile to go through the bounding box and not hit the player, and it just continues through its natural path.Unfortunately, when it DOES hit the player model, no matter where, it always bounces right back at me.
Any clue?
#3
// Otherwise, this represents a bounce. First, reflect our velocity
// around the normal...
Point3F bounceVel = mCurrVelocity - rInfo.normal * (mDot( mCurrVelocity, rInfo.normal ) * 2.0);;
mCurrVelocity = bounceVel;
If I were to guess, I'd imagine that rInfo is not getting its normal set properly.
Sure enough, on line 562, we've got...
if (getContainer()->castRay(oldPosition, newPosition,
csmDynamicCollisionMask | csmStaticCollisionMask,
&rInfo) == true)
Since castRay just calls objects to get collision info, I think there's a bug in the player ray cast handling code. Check there. (Or maybe make it print out the normals its getting so you can check that).
10/05/2002 (11:01 am)
Check around line 590 in projectile.cc// Otherwise, this represents a bounce. First, reflect our velocity
// around the normal...
Point3F bounceVel = mCurrVelocity - rInfo.normal * (mDot( mCurrVelocity, rInfo.normal ) * 2.0);;
mCurrVelocity = bounceVel;
If I were to guess, I'd imagine that rInfo is not getting its normal set properly.
Sure enough, on line 562, we've got...
if (getContainer()->castRay(oldPosition, newPosition,
csmDynamicCollisionMask | csmStaticCollisionMask,
&rInfo) == true)
Since castRay just calls objects to get collision info, I think there's a bug in the player ray cast handling code. Check there. (Or maybe make it print out the normals its getting so you can check that).
#4
10/05/2002 (5:55 pm)
It's probably going to mean tracing into the TS code where the LOS collision with the player mesh occures. You should probably print out the normals first to make sure that's the problem (can't think of anything else though).
Torque Owner Tim Gift