`In my game I have a Pen scene, which is made up of some RigidBody3D nodes. I instantiate this Pen scene twice in my Main scene, as player-pen and opponent-pen. I have coded the part where I’m able to apply impulse to the player pen so that it hits the opponent-pen.
Now I’m stuck at coding the basic AI for opponent-pen. I’m trying to read the position of the player-pen, to create an impulse which I can apply on the opponent pen, so that it hits the player-pen.
For some reason both the pens always show the same position value at which I had initialized them in the Main scene. Why is the position not updating?
I’m doing everything in the Main script and haven’t used _physics_process yet`
As far as i can tell you are apply an impulse on a child of “PlayerOne” this means only the child moves and not the player, thats why length_vector is always the same
I didn’t understand your comment. The length_vector calculated from P1.position -P2.position. Let’s take impulse out of the picture for now, because the problem is, the position of these pen, which is not updating as the pen move.
I just tried it, I printed the position of Pen/Top and it is indeed getting updated. I don’t get it, why the Pen as a whole don’t update its position, when clearly it is moving.
The parent is just a Node3D, you are moving the child, which also holds the visuals. The parent isnt moving at all its the child containing the visuals that are moving
Can you elaborate more on this comment, I’m not able to follow what you mean when you say only the child is moving. The white part, where I’m hitting, is a child of Pen, called Top. In the visual we can see the whole pen move, right?
The “Pen” is a node3d, it has NO VISUALS, so you cant actually tell if its moving.
It has children (i dont know what children it has, but probably meshinstance) with VISUALS and these children are moving.
Ooooh I see, the parent being a Node3D, has no physics or even a connection to the children. The children which are of type RigidBody3D, and connected to each other move, but that movement is not captured by the parent node.
Thank you, I understand it now.