Here is my problem. I want to be able to make objects such as the moving platforms in Mario in which they move back and forth and things can jump on it and what not (like Mario or a Turtle), but no object that hits it will affect its displacement or velocity.
I have heard things like moving a Static with SetXForm but that seems to be a hackish trick that could cause problems and does not allow for objects to "ride" on the platform by way of friction.
Is there an easy way to do this?
1 try using motors
2 maybe try setting it's mass to an insanely large number
Well I don't think I want to use an insanely large mass since it is still theoretically being sim'ed thus with time could slowly displace, plus any real contact with objects of lesser mass will result in an insanely large force put upon them.
I am assuming by motor you meant Prismatic Joint since you didn't really specify. Is there a way to convince the motor to go until it has reached one of its limits and just stop until we turn it back on again so it can go to its other limit and stop?
I'm also pretty sure it won't result in an insanely large force, it'll just transfer all of the momentum back onto the other object.
In terms of getting the platforms to move back and forth, maybe every update step check to see if the length = the max length of the joint, and if it does turn that motor off and turn the other on.
Or you could just apply a strong spring force guiding the platform (which is on a prismatic joint) towards a certain height (determined by some particular sinusoidal or otherwise cyclic function of time)
I always use x100 mass bodies for moving platforms and everything is ok! =)
Depending on what version of Box2D you're using, you might be able to use kinematic bodies for this.
As I understand it at least, using kinematic bodies would be the most 'correct' solution here. (Although it might work ok in some cases, I think having large mass ratios between objects is generally not recommended for numerical reasons.)