T3D 1.2 - Player can shoot self with Physx enabled
by Bryce · in Torque 3D Professional · 01/19/2012 (6:59 pm) · 22 replies
Build: 1.2 Pro
Platform: Windows 7 64-bit
Target: Game.
Issues: I recently enabled PhysX in my project, and the player is able to hit himself with his own projectiles when looking down. Somehow, activating Physx must have messed with the don't-collide-with-sourceobject checks in the projectile code. Thoughts?
Steps to Repeat:
1. Launch PhysX activated game.
2. Look all the way down, to where your feet would be if they were rendered.
3. Shoot.
4. Get damaged. Cry uncontrollably.
Platform: Windows 7 64-bit
Target: Game.
Issues: I recently enabled PhysX in my project, and the player is able to hit himself with his own projectiles when looking down. Somehow, activating Physx must have messed with the don't-collide-with-sourceobject checks in the projectile code. Thoughts?
Steps to Repeat:
1. Launch PhysX activated game.
2. Look all the way down, to where your feet would be if they were rendered.
3. Shoot.
4. Get damaged. Cry uncontrollably.
#22
I really need to add the time check instead for the player.
Will have to do it later.
Just a small note to this, I am using Bullet physics here.
One other reason for clearing out self shooting, Falling and shooting straight (or close to straight) down will produce self imolation as well without this mod.
03/11/2014 (1:05 am)
Slight modification to the basic raycast in projectiles:bool sameHit = false;
if (rInfo.object)
{
if (mSourceObject == rInfo.object || (rInfo.object->getTypeMask() & TriggerObjectType))
{
hit = false;
sameHit = true;
}
}I really need to add the time check instead for the player.
Will have to do it later.
Just a small note to this, I am using Bullet physics here.
One other reason for clearing out self shooting, Falling and shooting straight (or close to straight) down will produce self imolation as well without this mod.
Torque Owner Richard Ranft
Roostertail Games
Anyway, this was a problem that cropped up even with the built-in physics system. Just drop a time-stamp and the originating player on all of your bullets/projectiles, then when a player is hit check the data. If it's your bullet and it's been less than 32ms then it's probably the one you just fired, so don't do damage and don't remove the projectile. If this turns out to be too slow from script just move it into the engine. This was the basic solution for a while, then they just clamped the camera's vertical rotation range so you couldn't shoot yourself in the "foot" in built-in physics mode.
Not sure how you'd exclude the originating player using PhysX raycasts but I can't imagine that it would not be possible.