Bepu solid objects

Jul 24, 2012 at 10:42 PM

Hi again,

I'm trying to swap IGF's Bepu implementation into my project to replace Sunburns built in.

I cant figure out what to do with my SceneObjects that were previously set as Solid Objects.

I set the objects CollisionMove to a BoxCollisionMove and this seems to provide a boundingbox of the right size etc but I cant find any way to make it solid (immovable)

Any ideas?

Jul 25, 2012 at 11:31 AM

Here's a static box collision move for IGF that i use for exactly this purpose - it's just a drop in replacement for the standard box collision move

The only change from the standard is calling a different constructor for the Box space object.

            SpaceObject = new Box(
                (ParentObject.ObjectBoundingBox.Max.X - ParentObject.ObjectBoundingBox.Min.X) * CollisionObjectScale.X,
                (ParentObject.ObjectBoundingBox.Max.Y - ParentObject.ObjectBoundingBox.Min.Y) * CollisionObjectScale.Y,
                (ParentObject.ObjectBoundingBox.Max.Z - ParentObject.ObjectBoundingBox.Min.Z) * CollisionObjectScale.Z

Jul 25, 2012 at 12:31 PM
Edited Jul 25, 2012 at 3:41 PM

Thanks for the response, however when I used this class the objects still moved when objects collided with them. How do I make them solid?

Also I didnt have the .GetScaleComponent method of World so I used parent.World.Decompose to get the scale from there.

Jul 26, 2012 at 6:12 PM

Hmmm - i use exactly the same class and it works for me - i'm at a festival until tuesday i'm afraid, but when i get home i'll have a hunt around in my code and see if there was anything else i did to make the objects static

Jul 26, 2012 at 7:23 PM

Hey, thanks man that would be awesome!

I checked the IGF source and the class you posted seems to be the same as IGFs BoxCollisionMove.

Aug 2, 2012 at 12:28 AM

Hi again, did you happen to see anything else that you might have done to make objects solid?

Aug 2, 2012 at 1:56 PM

Hi luke,

If the above bamyazi code doesn't work for you, that's probably because you're setting the mass somewhere else in your code: setting the mass automatically makes the box dynamic and thus react to collisions. So make sure you don't set the Mass property in your CollisionObject instance and you should be good to go.

Another way for you to force it would be to call from anywhere in your code the BEPU BecomeKinematic() method of the Box entity like so:

// say your sceneobject is named SO:

var box = SO.CollisionMove as BoxCollisionMove;

Aug 3, 2012 at 10:52 AM

Hi Luke, 

What are you setting the CollisionType to on your SceneObject ??

You need to ensure that the CollisionType is set to 'Trigger' otherwise IGF will add a solver back to the static collision box making it dynamic again when the CollisionMove is initialized (Initialize method in the EntityCollisionMove code)

Aug 14, 2012 at 8:30 AM

Hi again,

Is there anything else I need to do, I still couldnt get collisions working.

I set the collision type to trigger like you said, and now the object is solid however collisions arent resolved and the object passes through.

Also I am not setting the mass in code however the object is added via the editor and so has a mass set to 1.0f

Aug 15, 2012 at 2:01 AM
Edited Aug 15, 2012 at 2:10 AM

I'm guessing you mean that some other object (your player object perhaps) passes through the static object ?

If this is the case you're probably setting the position of the player directly - ie. player.World = ???

Once you are using physics you can no longer use this method to move the player and need to manage movement by applying forces to the player collision object. We've discussed character controllers in a different thread and this is really what you need to implement to manage movement of your game characters. 

Aug 19, 2012 at 9:56 AM

No Im not moving it directly Im just creating a dynamic object above the static object and enabling gravity to test collisions between the two objects.

Aug 21, 2012 at 11:58 PM
Edited Aug 22, 2012 at 10:56 AM

Heres what I'm doing:

I made the following component which I add to scene objects to make them Bepu static collidables:


    public class BEPUCollidable : BaseComponentAutoSerialization<ISceneEntity>
        public override void OnAddedToParentObject()

            if (!(ParentObject is SceneObject))

            SceneObject sceneObject = ParentObject as SceneObject;

            sceneObject.CollisionType = CollisionType.Trigger;
            sceneObject.UpdateType = UpdateType.None;

            if (sceneObject.CollisionMove == null || sceneObject.CollisionMove.GetType() != typeof(BEPUStaticBoxCollisionMove))
                sceneObject.CollisionMove = new BEPUStaticBoxCollisionMove(sceneObject);

            var box = sceneObject.CollisionMove as BEPUStaticBoxCollisionMove;


 Similarly I give the player object a BoxCollisionMove. 

But the player passes through the scene object. An orange box is rendered around the scene object which turns red when the character passes through it. Also as you can see Im calling the BecomeKinematic method, but still no collisions!

Is there something I'm missing?