Adding Forces without moving the Node regarding

Hi,

the subject might be a little confusing so I’ll try to explain it a little better.



Here’s some background of my problem.

I went across this thread a few days ago: http://www.jmonkeyengine.com/jmeforum/index.php?topic=9456.0

I am dealing with moving the main character in my game as well and I liked the example, thank you.

Now here’s what I decided, since setLinearVelocity() leaves out gravity and addForce doesn’t work that well for a character I have to do it by just moving it with .setLocalTranslation(). Now there’s just an obvious problem, there is no longer any force in the same direction as the character moving and it doesn’t interact that well with other objects.



So to my actual question:

Can you without making the character move have a force that when interacting with other objects acts as if it was applied normally using addForce or setLinearVelocity



I’m sorry if I’m being unclear but I don’t really know how to say this

You could try using a contact callback to apply your force to the object you collided with. Not sure how feasible that is though.

Thanks but if I hit the side of an object I have to take that into account as well  :frowning: Arrgh I need something like setLinearVelocity but with gravity as well… You have any other idea of what I should try?

I can't figure out how I'm supposed to do this. If I move it using .setLocalTranslation I get two problems, it doesn't react the way it should with other object and I can by mistake go straight through the floor, if I move it with addForce I get a problem with forces and velocities in the wrong direction, I could fix that with .clearDynamics() but that would turn off the gravity and all other velocities. Finally I could use .setLinearVelocity() but that would just like .clearDynamics turn off gravity and all other velocities. What should I do?



Please help me…



You have been very helpful and I'm rude to continue to ask this but I really need a good solution for moving a FPS character

I'm very greatful for all the help I can get, Thank you.

there is another callback you can use. I forget the name off the top of my head. Anyway, it gets called every iteration of the physics engine, you can then use your clearDynamics approach, and then in the call back manually apply your gravity force.

Another approach is to write a custom joint, but I've never actually seen this in practice.

nymon said:

Another approach is to write a custom joint, but I've never actually seen this in practice.

Something like this is the way to go, I think. Have a look at PhysicsPicker and create something like it which is controlled by you movement controls instead of mouse.