Hello. I am trying to use the Panda3D built-in physics system to apply gravity on my panda model, but when I set the panda’s z to 100, it just stays there. Code:
It’s probably in the scene-graph, but outside the camera’s view.
Still, that seems to show that setting the z-coordinate does work.
What I think is happening is that you’re setting the z-coordinate on an object with a scale of 0.005. As a result, a z-coordinate of 100 in the object’s coordinate-space has a value of 0.5 in the world’s coordinate-space, if I’m not much mistaken.
I want the panda to fall down from z 100 to z 0.
What do you mean by setting scale in a diffferent node and pos in different node.
Like this?:
np -> pandaNode -> posNode -> scaleNode
If yes, how?
Okay, you simply have the order of your nodes mixed up, by the looks of it.
Think of it this way: Consider a node attached as a child of another node to be located “below” that node in the hierarchy. Looking at it this way, transformations (e.g. positions, scalings, etc.) affect the node to which they’re applied, and any nodes below them. They don’t affect nodes above them.
In this case, you have your physics-node, and below that your model, and below that your position-node, and below that your scaling-node.
As a result, change to your physics-node affect all of the others; changes to your model affect the model, your position-node, and your scaling-node; changes to your position-node affect your position-node and your scaling node; and changes to your scaling node affect only your scaling node.
Thus, if you want your position-node to affect your physics-node, you can achieve that by placing it “above” the physics-node in your hierarchy. If you want your scaling node to affect your model, but not your physics-node, then you can achieve that by placing it “above” the model, but below the physics-node.
One thing does occur to me: since you want to move the object, and have it be moved by physics, it might actually be better to drop the “position” node and instead just adjust the position of the “physics” node. That should be unaffected by the scaling, and should mean that you don’t have the effects of the two nodes disjointed.
In which case, you might be able to drop the “scaling” node, too, and just scale the model: since you would no longer be trying to move a node that’s scaled, there should be no more conflict.
More than that: I’m saying that you can use your “physics”-node as your “position”-node, and your model as your “scaling”-node, meaning that you don’t need separate “scaling”- and “position”- nodes.
(Although you may later want similar intervening nodes if you find yourself wanting to do more-complex things, of course.)
That it’s not falling down is a separate issue from positioning and scaling, I believe. Sorry, I thought that the original problem was the positioning of the model, not that it wasn’t responding to gravity!
Unfortunately, I don’t use Panda’s physics system (only its collision system, and the Bullet physics system). Thus I’m afraid that I don’t know much about setting up gravity in Panda’s physics system.