Game Development Community

[bug] weapon -> trigger collision

by Marcus L · in Torque 3D Professional · 11/23/2009 (4:00 pm) · 14 replies

Collision is applied to 1st person weapon when walking through triggers. Not such a big issue but would like to get it fixed.

Thanks.

#1
11/23/2009 (4:12 pm)
Previously reported in 1.01 linky

Possibly caused by the pushback code, only occurs when using eyeoffset (which utilizes said pushback code).
#2
11/23/2009 (5:14 pm)
@ Steve
The fixes you posted are already applied to the new build (1.1), cant seam to get it to work.

Could you post the line piece of code that i have to change?
#3
11/23/2009 (5:19 pm)
Yeah I know that link to links don't make any difference, just mentioning that it's been reported - though apparently no fix for this yet.
#4
11/23/2009 (8:48 pm)

Think the culprit is this:

if (getContainer()->castRay(start, end, 0xFFFFFFFF & ~(WaterObjectType|DefaultObjectType), &rinfo)) {
      if (rinfo.t < 1.0f)
         mWeaponBackFraction = 1.0f - rinfo.t;
      else
         mWeaponBackFraction = 0.0f;
   } else {
      mWeaponBackFraction = 0.0f;

It is including way too many object types in the collision mask. Try changing that to:

if (getContainer()->castRay(start, end, sCollisionMoveMask & ~(WaterObjectType|PhysicalZoneObjectType), &rinfo)) {
#5
11/23/2009 (8:49 pm)

Hehe... some general info about where this is would probably be helpful :)

It's Player::calcClassRenderData
#6
11/23/2009 (8:57 pm)

Yep, fixes it. Checked in for 1.1 Beta.
#7
11/23/2009 (9:35 pm)
And after I eventually managed to rebuild the correct solution ...

Yep, that seems to have cleared up that little problem, Rene.
#8
11/24/2009 (4:38 pm)
One further thing that occurred to me is that this function should really use castRayRendered, i.e. perform collision-detection against rendered geometry rather than collision geometry. Collision geometry is always just a rough approximation and simply not good enough for the weapon retraction which has the sole purpose of preventing *visible* object intersections.

Still, even with that change you get visible interpenetrations as the code does not take the actual volume of the weapon into account but rather just shoots a single straight ray. What it really needs to do is intersecting either the world box or (better yet) the collision geometry of the weapon with anything that is close to it and then push the weapon back far enough to get clear of any geometry that it would otherwise intersect with.

Finally, the retraction here is entirely a first-person rendering trick, i.e. we do not actually make the player shape lower its weapon which in fact we should do.
#9
11/24/2009 (5:45 pm)
Thanks Rene, It Works!
#10
02/05/2010 (5:38 pm)
Hey guys. I have a possibly related issue. I have a character that is throwing a grenade, and the grenade is bouncing back off of triggers. The grenade is a "new Item()". How can I stop it from physically colliding with triggers?
#11
02/05/2010 (5:49 pm)

Taking TriggerObjectType out of the server collision mask should do the trick:

const U32 sServerCollisionMask = (sClientCollisionMask |
                                  TriggerObjectType); // remove this

Actually not quite sure why this is in there since I *think* trigger collisions are handled differently. Have to check that.
#12
02/05/2010 (8:18 pm)
Perfect, thanks a lot!
#13
06/06/2010 (1:27 pm)
Logged as TQA-247.
#14
06/10/2010 (4:57 pm)
Confirmed as fixed for 1.1 Beta 2.