How to simulate a rocket thruster?

May 16, 2009 at 8:05 PM

Hi all,

I've read the manual and I still have some doubts how to go about creating something like a rocket thruster by using only the available joints & springs.

I've thought about the linear spring, but can't figure out how to determine the axis on which the force will be applied.

Has anyone tried something like this? I'd rather use constraints than use ApplyForce directly, since it usually results in more stable simulations.

Thanks for the help!

Gonçalo

May 17, 2009 at 2:15 AM

1st off, I would appreciate it if you put all your posts in one if you know them all before hand, many threads clutter the discussions and push back other peoples questions.

But to answer your question your question I need you to be more specific

What type of situation are you exactly trying to simulate?

A rocket just launching vertically?

A rocket launching out of a cannon at an angle?

A jetpack?

I am not sure what exactly your trying to do that applying a force isnt sufficient

May 17, 2009 at 3:19 AM

Hes saying that applying a force would work but he would prefer to use some constraint to effect the movement. Also, i think he wants a jetpack.

May 17, 2009 at 7:40 AM

ok that makes a tad more sense,

but is he talking about constraining the user of the jetpack?

Like say using an angle joint so they dont go rotating all around?

Or like a force to oppose the force to get a rebounding effect,

im sorry but i really dont know what the question is, i see basically

"figure out how to determine the axis on which the force will be applied"

Which i interpret as

"I cant figure out a way for it to automatically determine to apply force on the x or y axis"

 Which makes me think hes looking for AI pathfinding techniques for some jetpack user,

Thats probaly extremely wrong which is why id love a bit more information on what hes looking for

May 17, 2009 at 9:17 AM

I think he wants the person to be able to hover and to move smoothy and easily through the air.

Applying a force would work if you wanted the player to control their thrust, ie. each time you press UP a force is applied. If you dont press up you will fall. If you tap UP you will fall slowly etc.

If you wanted the player to remain hovering when no buttons are pressed, and to move up and down at a fixed speed, Id reccommend a fixed revolute joint. To move the player, move the ANCHOR of the joint. To stop the player SWINGING around, apply a fixed angle joint to him.

 

Hope that helps

May 17, 2009 at 9:37 AM

ooooops..... by jetpack i meant space rocket type thing. the english language is so hard at times >_<. he saying how do i, given a thrust direction (in radians) and strength, convert that to movement of the player object. On that note, ApplyForce ought to work just fine (unless you're dealing with HUGE forces, whouch shouldnt be the case), so take the stick input (i assume you're using a stick for movement?) and multiply the Y by negative 1 (to compensate for the fact that up is positive on the stick and down is positive on the screen), then multiply that by the force amount and use that to apply force.

May 17, 2009 at 10:26 PM

Hi again,

First of all, I'm sorry for the multiple threads. I just wanted to keep the posts logically separated, since they refer to different topics which could then be followed upon independently. Regardless, I'll keep the suggestion in mind for the future.

I'm sorry if my question looks a bit silly in the context of Farseer Physics. I myself come from an ODE physics background, where basically you do everything using constraints, since you usually end up having more control and greater stability over the simulation. In fact, it is highly recommended never to apply forces directly in ODE. I don't exactly have any specific situation in mind, I just wanted to know more about the best practices in using Farseer before delving deeper into the game design.

Another reason why I asked about joints and springs was to see whether there was anything in Farseer similar to the Linear and Angular motors in ODE. The difference with using motors instead of forces directly is that you can control the movement using desired velocities, leaving up to the motor the decision of what exact force should be applied, depending on motor capacity, body mass and other motor constraints. The consequence is that you usually require far less magic numbers in your system description for everything to fall into place, since the motor does everything for you automatically.

Maybe this is a bit of an overkill for 2D physics, so I'll try to implement my systems using apply force directly for now, and see where it leads me.

Thanks for all your feedback,

Gonçalo

May 18, 2009 at 10:45 AM

> I myself come from an ODE physics background, where basically you do everything using constraints, since you usually end up having more control and greater stability over the simulation

sounds unusual, but intereseting. do you have some examples?

May 18, 2009 at 2:44 PM

> sounds unusual, but intereseting. do you have some examples?

ODE has a general-purpose constraint solver that takes into consideration the set of constraints applied on a simulation body and computes corrective forces for that step. The current implementation is pretty stable and robust, as long as you play by the rules.

This means that you can do things like attaching a spring to a launching rocket as two different constraints and ODE will compute the combination of these constraints in the best way to keep the simulation accurate and stable. It also means that you don't have to make the tweaking yourself, as the ODE solver will do the math for you.

This also typically reduces the amount of magic numbers required.

Best regards,

Gonçalo

Coordinator
May 18, 2009 at 3:51 PM

@yobiv: It is interesting indeed. Box2D uses a similar design in their engine; it is simpler that way in some cases. Imagine a revolute joint with a motor. When you apply force to the motor, it rotates the body it is attached to, even if there is an offset in the position of the revolute joint.

@glopes: Farseer Physics focuses on simplicity. Even tho we are in the progress of implementing SAT, shapes, CCD and other features, we aim to have a simple and useful engine without too much stuff in it. Simple in the sense that both our users can use it easily, but also simple in the sense that developers can understand what is going on and build their own engine based on ours.

The ultimate goal is to have a fast, robust and simple simulator. Right now I think the stability is ok, but in the future we might implement position correction (more info here) and motors. Who knows :)