Collision Question / Issue

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
maxx2310
Posts: 2
Joined: Tue Sep 30, 2014 3:51 am

Collision Question / Issue

Post by maxx2310 »

Hello,

I am testing out BEPU or any physics engine for that matter, but I decided to try this one out first and I am running into an issue where I can collide with a handful of boxes and then the player controlled object will not collide with any other objects the rest of time. I currently have all the objects setup as boxes.

Code: Select all

Player.Boundary = new BEPUphysics.Entities.Prefabs.Box(new BEPUutilities.Vector3(10, 10, 0), 32, 32, 32, 2);
I see quite a few settings and wondering which ones I may need to set to ensure all the objects will continue to collide.

In addition I am building a 2d game using top down view and currently using the ApplyLinearImpulse to move the character which works fine for the most part but I am curious is there a way to prevent the characters from sliding all over the place? Thanks in advance for any help!

Code: Select all

        public override void Move(DirectionHeading direction, bool sprint)
        {
            Direction = direction;

            float adjustedVelocity = Properties.ValueOf(Database.Common.Velocity);

            if (sprint == true)
            {
                adjustedVelocity *= 2.0f;
            }

            Vector3 pulse = new Vector3(0, 0, 0);
 
            switch (direction)
            {
                case DirectionHeading.East:
                    pulse.X = adjustedVelocity;
                    break;
                case DirectionHeading.West:
                    pulse.X = -adjustedVelocity;
                    break;
                case DirectionHeading.North:
                    pulse.Y = -adjustedVelocity;
                    break;
                case DirectionHeading.South:
                    pulse.Y = adjustedVelocity;
                    break;
            }

            Boundary.ApplyLinearImpulse(ref pulse);
        }
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision Question / Issue

Post by Norbo »

I am running into an issue where I can collide with a handful of boxes and then the player controlled object will not collide with any other objects the rest of time. I currently have all the objects setup as boxes.
Assuming there are no collision rules defined to explicitly disable collision, I would suspect a mismatch between the physics representation and the graphical representation. Anything the character can appear to move through freely may actually be in a different location.

Colliding is the default behavior for dynamic entities and there is nothing in the engine which would change collision behavior at runtime by itself.

Playing around in the BEPUphysicsDemos may be valuable. In addition to showing how to set up a bunch of simulations, it can show what sorts of things are expected behavior, and what sorts of things aren't.
In addition I am building a 2d game using top down view and currently using the ApplyLinearImpulse to move the character which works fine for the most part but I am curious is there a way to prevent the characters from sliding all over the place? Thanks in advance for any help!
Impulses could be applied to decelerate the rigid body, just as they are used to accelerate it. There's also things like Entity.LinearDamping which remove energy from the entity over time. If you want to operate at the velocity level, setting the LinearVelocity directly would be easier than trying to use impulses. You can think of setting LinearVelocity as applying an impulse of just the right size to get the velocity to the desired value.

That said, creating robust character-like behaviors can be very tricky. If the character's desired movement is well-represented by CharacterController, using it can save a lot of time. The CharacterControllerInput class in the BEPUphysicsDemos shows some simple usage of the CharacterController.
maxx2310
Posts: 2
Joined: Tue Sep 30, 2014 3:51 am

Re: Collision Question / Issue

Post by maxx2310 »

Awesome thanks Norbo for taking the time to respond, I will give another look at the demo's to see what I am potentially doing wrong, I believe the graphical representations are correct on the client side, only because the way I have the server and client setup is the server has total control over the physics and positioning, I dont have any simulations going on the client side currently. But let me play around with the demo's some more.
Post Reply