NVIDIAGameWorks / PhysX

NVIDIA PhysX SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Looking for guidance on triggers, and in general (enemy bullets hitting player ship)

PcChip opened this issue · comments

Hello,

Image here to set the stage: https://i.imgur.com/JXkbSMX.png
In the image, a turret shoots kinematic trigger balls towards the player, which is a character controller (very skinny in this screenshot) and another shape that is the shape of the ship to notify when bullets hit it

TL;DR - I'm looking for some guidance in general on the following: How should I treat enemy and player bullets, the character controller, and the shape of the player's ship? Since the CCT does not match the shape of the ship, I do not want bullets to interact with the CCT Capsule Shape in any way!

I'm using a character controller so that I can have collisions with the terrain, and enemy buildings. However, it doesn't fit the shape of the player ship perfectly, so I'm trying different methods to make a shape to catch bullets...
I've tried:

  • attaching the ship shape to the Character Controller Actor, using various flags on this shape. However I could not get the ship shape to rotate and match the correct orientation whatsoever, it was always pointing straight up!
  • creating a new ridigdynamic actor (kinematic) with this ship shape, and moving this kinematic actor to wherever the CCT goes (currently seen in the screenshot)

The problems I'm having is the following: I cannot figure out a combination of actors/shapes/flags to make my goal work. (the shapes either interact with each other and push each other away, or don't interact at all and do not cause a trigger callback or collision callback.) I just need a character controller to collide & slide with the ground, and a shape for the ship to notify when bullets hit it!

Should I use kinematic objects for the bullets? Trigger shapes?
Should I use a kinematic object for the "shell" of the space ship?

= New Trigger Method (Simulation Filter version) =
I also tried making both triggers, but they would not interact. That's when I found @PierreTerdiman 's posts on the Unity forum explaining why those were deprecated, and saying that people should be using newer methods (included in TriggerSnippets), so I began trying that as well. I'm having several problems with that method:

  • I can't get it to work (trigger against triggers)
  • but more importantly, how would layers work? if I set the FilterData to the following:
    PxFilterData emulatedTriggerFilterData(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
    then how can I make collision filtering work? For example if I want the player's ship shell to be a trigger, and the enemy bullets to be a trigger, and I use this "new trigger method" to fake triggers, then how can I use layers if it's set to 0xffffffff, 0xffffffff on both? (would that mean they interact with everything?)

Thanks for any help you can provide, I'm just feeling really confused on all the possible options and can't seem to make any of them work for what I'm trying to do!