How can I make player detector not affect by gravity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

How can I make player detector not affect by gravity

Post by parapoohda » Wed Jul 17, 2019 9:26 am

I want to use collision to make player detector for player and monster.
Now I can make it not collide with other collidable by make this function
AllowContactGeneration
return false
And not affect by gravity by
make function in DemoCallbacks return false.
But what I have to inherit from (I want to add other property eg. isAffectByGravity or isColiidable ) .
Is it collidable or pose

Darkon76
Posts: 23
Joined: Mon Mar 27, 2017 12:33 pm

Re: How can I make player detector not affect by gravity

Post by Darkon76 » Wed Jul 17, 2019 3:14 pm

Hi,

By default bepu 2 doesn't have collision groups, you need to implement them manually, the best place to do it is creating a custom INarrowPhaseCallbacks, that handle the collisions.

The DemoPoseIntegratorCallbacks, apply the gravity to all objects. So you need to create your custom IPoseIntegratorCallbacks that don't apply the gravity to selected objects. The easier way that don't modify the original library is adding a list at your custom PoseIntegrator.

Norbo
Site Admin
Posts: 4708
Joined: Tue Jul 04, 2006 4:45 am

Re: How can I make player detector not affect by gravity

Post by Norbo » Wed Jul 17, 2019 11:17 pm

For an example of what Darkon described, check out the SubgroupFilteredCallbacks in the RagdollDemo. The brief explanation is that the custom data used for the callbacks is outside the engine in whatever format you find convenient. (In the demo, it's stored in a BodyProperty<T>, which is just a simple per-handle array of data.)

Generally, there's not much point to modifying the in-engine body data, and attempting to stick more data into those data structures can actually have some negative side effects. The in-engine Bodies arrays are packed according to in-engine access patterns, so sticking more data into them risks cache line inefficiency and higher bandwidth requirements.

parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

Re: How can I make player detector not affect by gravity

Post by parapoohda » Thu Jul 18, 2019 1:36 am

Thank you very much for both answer. I will look into SubgroupFilteredCallbacks. I will ask again if I don't understand anything. :D :D

parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

Re: How can I make player detector not affect by gravity

Post by parapoohda » Wed Jul 24, 2019 10:56 am

I have question about make player detector. Is broad phase narrow enough for make player detection( If i make player dector 16 metre radius sphere is it will be narrow like 60 - 70 metre). Or it is too broad some time(Or it range can be anything).

I have another question.
Can should I use Compound buider with character and playerdetection. Or I should add it separately. If it should add separately how do I munipulate it? make is same mass and velocity?

Thank you. You are very nice.

Norbo
Site Admin
Posts: 4708
Joined: Tue Jul 04, 2006 4:45 am

Re: How can I make player detector not affect by gravity

Post by Norbo » Wed Jul 24, 2019 9:09 pm

I have question about make player detector. Is broad phase narrow enough for make player detection( If i make player dector 16 metre radius sphere is it will be narrow like 60 - 70 metre). Or it is too broad some time(Or it range can be anything).
If you mean broad phase queries using Simulation.BroadPhase.GetOverlaps, then it'll find any collidables in the broad phase whose bounding boxes overlap the input bounding box. It won't check at the level of narrow phase contact generation. So it won't be as tight as checking contacts with a collision shape, but it won't be any looser than the bounding boxes of the shapes involved.

If you mean using the INarrowPhaseCallbacks.AllowContactGeneration to collect overlaps, that'll have equivalent tightness to the BroadPhase.GetOverlaps. It'll be called for any objects with overlapping bounding boxes.

If you mean using the INarrowPhaseCallbacks.ConfigureContactManifold to receive notification of contacts being generated (and then presumably returning false for detector-involving pairs so no constraint is created), it'll provide full detail information about the collision- if there exist any contacts in the reported manifold with nonnegative depth, then the collidables are touching.
Can should I use Compound buider with character and playerdetection. Or I should add it separately. If it should add separately how do I munipulate it? make is same mass and velocity?
You could use a compound and then prevent contacts with the detector child by using the child-aware callbacks, yes. You could also use a separate object too; you'd probably want such a separate detector to be kinematic and just set to the same velocity and position as the character each timestep. Since it won't actually be generating any constraints, it doesn't matter if it's actually connected to the character. You could just pick whichever one is easier for you.

Another option for player detection are the BroadPhase.GetOverlaps queries I mentioned earlier. Often, player detection doesn't require super tight accuracy, nor does it require checking every single character every single frame. If that's the case, then periodically using BroadPhase.GetOverlaps will tend to be faster and simpler to use.
Thank you. You are very nice.
:P

parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

Re: How can I make player detector not affect by gravity

Post by parapoohda » Thu Jul 25, 2019 2:48 am

Thank you Norbo. You are always answer my question. :D :D

parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

Re: How can I make player detector not affect by gravity

Post by parapoohda » Thu Jul 25, 2019 5:58 am

I try to make BoundingBox by its construction. So I need character position. How can I get it from bodyhandle. Thanks.

parapoohda
Posts: 38
Joined: Fri May 31, 2019 6:30 am

Re: How can I make player detector not affect by gravity

Post by parapoohda » Thu Jul 25, 2019 6:38 am

Find position of object

var position = new BepuPhysics.BodyReference(bodyHandle, Simulation.Bodies).Pose.Position

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests