Using forces for objects movement

So I hit the problem which I have read about multiple times in this topic.



Movement using jbullet of my objects.



So I read up and read previous threads and they seem to mention DynamicPhysicsNode quite a lot :http://www.jmonkeyengine.com/forum/index.php?topic=10233.0



Problem is I cannot find this inside jme3.



What I am trying to do at the minute is :



  model.applyCentralForce(force);



which results in no movement of my node.

If i do


model.applyContineousForce(true,force);



then my model goes upwards to infinity.

The examples I have read about use the .addForce(force) method - however I dont have access to that in my PhysicsNodes

Help!?

Ok, the main difference between "applyCentralForce" and "applyContineousForce" is that the former applies it only once, and the later applies the force all the time (that's why it goes till infinity). Try to move it with the first and a greater force, or the second and stop when you have moved it enought.

Right well im doing



.applyCentralForce(new Vector3f(0,100,0));



and the thing doesnt move…

I looked inside the code and I didn't saw anything weird, but I didn't do it, so you should actually wait 'till someone who knows better comes and says what's happenning.

renegadeandy said:

Right well im doing

.applyCentralForce(new Vector3f(0,100,0));

and the thing doesnt move.....


You probably try to set this value once when you press a key or smt. In that case its really better to use continuousForce and enable/disable it on mousedown/mouseup.

The applyForce methods are more for continuous checks because in fact they are reset each frame but bullet uses an internal framerate of 60fps. So only when the frame where you hit the button is the frame where the physics "really" get updated it will be applied.

Otherwise, theres applyImpulse(force, relativeLocation) if you really just want to apply an impulse to the node, it will be executed the next physics update no matter when you set it.

Ahh i see - so if i wanted my character to jump i could do apply continuous force on keydown, then keyup disable the force.



So an impulse is like a one time issue.

renegadeandy said:

Ahh i see - so if i wanted my character to jump i could do apply continuous force on keydown, then keyup disable the force.

So an impulse is like a one time issue.

Well in fact jumping would be an impulse in the up direction, continuous force upwards is like a jetpack that you turn on and off.

Right, so im making a snowboarding game.



So i reckon forces are applied as impulses, does that make sense? so you would apply an impulse force slightly to the left, right, ahead, or behind you to help direct the board? What about rotations then, how are they handled - do they occur in the physics world?



Lets say i wanted to swing the board to the left slightly, do you apply a physics force to do this?

Rotation in physics is called torque. And no, impulses would not be a proper way to simulate a snowboard, thats like shooting a gun out of the window to steer the car.

If you want to really "control" your snowboard you will have to check the current forces with getLinearVelocity and getAngularVelocity and give correct counter forces on your snowboard each tick. So if your torque around the x-axis is too high, you apply a counter-force. In this case using addForce() will work since you do it every tick.

addForce()? Where is that method…

renegadeandy said:

addForce()? Where is that method...

I mean the applyForce methods, turn on your brain.

Gratz to your 1000th post! And what a post  }:-@  XD

Are you telling yourself to turn your brain on, or me.



As far as im concerned it was your brain which was off.

Whoa norman is badass. Thats a new thing.

Congrats on the 1000 post!

who is norman?

renegadeandy said:

who is norman?

LOL!  good joke!

rofl :slight_smile:

so I guess norman is my evil alter-ego  }:-@

If you want to really "control" your snowboard you will have to check the current forces with getLinearVelocity and getAngularVelocity and give correct counter forces on your snowboard each tick. So if your torque around the x-axis is too high, you apply a counter-force. In this case using addForce() will work since you do it every tick.


Itd be real nice if there was an example of this. What is the difference between linear velocity and angular? This is not a simple set of instructions in all honesty without an example.