This project has moved and is read-only. For the latest updates, please go here.

Objects moving through other objects?!

Topics: User Forum
Dec 18, 2006 at 7:12 PM
Help! I'm a little stuck with my project i've got going.
The RectangleRigidBodies fall through the "floor" i've set using ScreenCollision Border.... could someone please outline to me the basic requirements/rules of how to use the PhysicsSimulator class correctly?

When i run it at the moment the objects stay on the floor i've set for a while.. then wobble for a while then fall through. Sorry if i sound a little helpless :D

It would be really nice if there was a basic demo showing you how to use JUST the Physics class... great class by the way. I really like it and it has saved me a lot of time and effort programming my own physics.
Dec 18, 2006 at 8:06 PM
Some of my earlier demos were more basic. They will not run due to the fact they were written against the xna beta, but you should be able to update them pretty easily.. or at least look at the code.

Not sure what is going on with your app. Usually it's just some settings that aren't setup correctly.

I really need to get some docs out...
Dec 21, 2006 at 6:12 PM
its ok now.. i got it working :D turns out my variables were wrong, so i had to spend some time messing with the gravity, friction between the blocks and mass of the blocks till it worked.

it would be REALLY great (and much easier for people who have just found this ace project) to include the first few demos updated to the final version of xna in your next release... so people can look at how to do things.

finally, yet again, i'd like to thank you for saving me the effort of programming overly complicated physics into my game.
Dec 22, 2006 at 5:02 AM
Yes, I agree the porting the first few demos to 1.0 would be helpful. I'll try to get that done this weekend.
Dec 23, 2006 at 5:32 PM
i'm getting a little further with my project now... and i've realised that it might be useful if i had a series of rigid bodies connected together as joints...

i've found the RevoluteJoint class.. but for some reason the constructor won't let me use RigidBody?!

also do you have to then add BOTH rigidbodies via the Add() method on physicsSimulator, or do you just have to use AddJoint() ?
Dec 24, 2006 at 1:27 PM
For the revolute joint.

Create both rigid bodies.
Add them to simulator.

Create RevoluteJoint passing the rigid bodies you want to connect and the world position where you want the joint. (this world position will be used as the starting position of the joint.)

NOTE: When creating the revolute joint, if you are using the RectangleEntity or PolygonEntity from my FarseerXNAGame framework, you can't pass the entity itself in the constructor for revolute joint, you must pass entity.RigidBody.

Hope this helps.

Jan 14, 2007 at 8:27 PM
how to you get the world position for the constructor?
All i want is to just connect 2 rigid bodies together... I've got the joints working better now, and currently i've just set the position parameter to Vector2.Zero.

btw what does the RigidBody.GetWorldPosition(Vector position) do? Could i pass the position of one of the blocks through here to get the world position?

Why do you need a world position and a local position?
Jan 15, 2007 at 1:01 PM
The world position is just where in the world the joint is positioned.

The GetWorldPosition takes a position relative to the rigid body and returns it's world position.

In the example, I think I probably wanted the joint to be positioned relative to one of the bodies so I used the GetWorldPosition to get the anchor position for the joint.

The anchor is a world position because there are two bodies.. If the anchor were relative then which body would it be relative to?

Hope this helps.