Page 1 of 1

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

Posted: Thu May 08, 2008 11:15 pm
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!

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

Posted: Fri May 09, 2008 12:20 am
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.

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

Posted: Fri May 09, 2008 2:24 am
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.

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

Posted: Fri May 09, 2008 2:36 am
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!

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

Posted: Fri May 09, 2008 2:37 am
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