I add bodies dynamic rapidly and character fall of floor

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

I add bodies dynamic rapidly and character fall of floor

Post by parapoohda »

I add bodies dynamic in front of character and character is fall of floor

here are my code when add

Code: Select all

           
            var handle = Simulation.Bodies.Add(BodyDescription.CreateKinematic(trigger.StartPosition, collidable, new BodyActivityDescription(-1)));
I want it to passthrought character so I make function isPassthrought

Code: Select all

 private bool IsPassThrought(CollidablePair pair) {

            bepu.EventContactInit(pair.A.Handle, pair.B.Handle);
            var a = bepu.GetHandleUnit(pair.A.Handle);
            var b = bepu.GetHandleUnit(pair.B.Handle);
            if (a == null|| b == null)
            {
                return true;
            }
            var isPassThroughA = bepu.GetHandleUnit(pair.A.Handle).Collider.isPassThrough;
            if (isPassThroughA)
            {
                return false;
            };
            var isPassThroughB = bepu.GetHandleUnit(pair.B.Handle).Collider.isPassThrough;
            
            if (isPassThroughB)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
thank you :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I add bodies dynamic rapidly and character fall of floor

Post by Norbo »

Sorry, I'm not sure exactly what you mean, so I'm going to make a best guess-

It sounds like you're trying to make a trigger object that doesn't collide with the character, so you made a collision filter for use in the narrow phase callbacks that avoids generating contact constraints if the body metadata is flagged as passthrough. Now, the character sometimes falls through the ground inappropriately.

If I understand that correctly, it may be because the collidable pair being passed to the function includes a static object. That function doesn't distinguish between statics and bodies, and it's possible for a static and body to have the same handle. So the GetHandleUnit fails to find the static-associated metadata (or finds the wrong metadata), causing it to fall through.

If that's the issue, then taking into account the CollidableReference.Mobility property will help. Bodies and statics have separate handle 'namespaces', so you should check if the mobility is Static before trying to use the associated handle.
parapoohda
Posts: 92
Joined: Fri May 31, 2019 6:30 am

Re: I add bodies dynamic rapidly and character fall of floor

Post by parapoohda »

Thanks I will look into it. Yeah I try to make trigger that not collide
Post Reply