Position of a Node3D is not updating even when it moves in the game

Godot Version

Godot Engine v4.2.2.stable.official.15073afe3

Question

`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`

Can you show your code?

Hi @herrspaten
Here’s the function ai_pen_turn() which I call from _Input(event) function

And I always get the same length_vector_ value no matter where these pens are. Which is unexpected.

Let me know if I you need more info to help me here.

Thank you!
Amit

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.

How does the pen move?

I apply this impulse. Oh, I see what you mean. So, are you saying that since the impulse is on the child, the pen position doesn’t change?

But I have used this node “Generic6DOFJoint3Dnode” to make sure all the children stick together. And also in the visuals I see the whole pen move.

Yes but then you also need to check for the children postion and not the parent, which doesnt 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.

1 Like

yes, position rotation and scale is only applied to children and not the other way around

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.