I can't believe I'm asking this...

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
DarkKnight7
Posts: 2
Joined: Thu May 08, 2008 11:04 pm

I can't believe I'm asking this...

Post by DarkKnight7 »

...but I'm having trouble getting my entities to move at all. I have created a static triangle group out of the "playground" model, and I made a Box. I added both of those entities to the space, and set the space's gravity. I also have the space's update method getting called.

However, when I run the program, the box stays stationary. I attached the BepuBox model to the phys box, but it doesn't move. I then went into the debugger, and after about 2 seconds, I tell the program to break so I can look at the variables. The position of the box always stays where I initially told it to be created.

I thought I copied all of the necessary code from the Demo source sample, but I guess not. Is there something really obvious that I'm missing?

Thanks for your replies!
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: I can't believe I'm asking this...

Post by Zukarakox »

Which position are you checking? You have to tell the model to follow the box, it is one of the constructors for DisplayModel, so if you didn't do that and you're checking the model's position, it won't move :P

Make sure you didnt set the gravity before initializing space.

Other than that, I got nothing.

Edit: Can you paste the code where you create the box? I think I know what you're doing.
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I can't believe I'm asking this...

Post by Norbo »

I'm guessing what Zukarakox suspects is that you might be using the nondynamic constructor of the entities. If you don't give them a mass, they default to nondynamic (which essentially means infinite mass in terms of simulation).

The two constructors are:
Box box = new Box(Vector3 position, float width, float height, float length)
Box box = new Box(Vector3 position, float width, float height, float length, float mass)

Each entity (other than the CompoundBody) follows this double-constructor pattern, and each entity also can be made dynamic or nondynamic by using the (entity).makePhysical(float mass) and (entity).makeNonDynamic() methods.

From there, just add them to your Space with the add method. Note that the default gravity is (0,0,0), so that would need to be changed if you want it to fall and bounce around.
DarkKnight7
Posts: 2
Joined: Thu May 08, 2008 11:04 pm

Re: I can't believe I'm asking this...

Post by DarkKnight7 »

Aha! I knew it was something stupid on my part. You're right, I was using the non-dynamic constructor. Thanks for the help, both of you. That had me stuck for quite a while.

Also, I wanted to say thanks for the awesome physics engine you made. It's definitely the most helpful XNA project I have ever used!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I can't believe I'm asking this...

Post by Norbo »

DarkKnight7 wrote:Aha! I knew it was something stupid on my part. You're right, I was using the non-dynamic constructor. Thanks for the help, both of you. That had me stuck for quite a while.

Also, I wanted to say thanks for the awesome physics engine you made. It's definitely the most helpful XNA project I have ever used!
Thanks for trying it out :D
Post Reply