[Solved]How to move a node with mouse click on a moving model

im trying to move my player(node) on an island model which is rotating around a center position using SpatialTransformer.

the island node has a child model, a child player node. the node localtranslation of the island defines the rotating center, and the model defines the radius.

right now the player rotates around the center with the island model if i dont move the player(clicking mouse). but if i try to move the player, it doesnt move relative to the island model. and after it reaches the new position, it doesnt rotate with the island model anymore.

help plz! :’(

Why don't you make your player a child node of the island so it will always be moved with it?

duenez said:

Why don't you make your player a child node of the island so it will always be moved with it?

it is a child of the island...

the island node localtranslation is the center which is 0,0,0

but the model of the island is at some other local which defines the radius of rotation.

when i change the player's local to where the mouse was clicked, the player doesnt follow the island model anymore. but it still rotates around the island node which is the 0,0,0 center

and just to make things clear.

when i dont move the player meaning i dont click the mouse anywhere, the player does move with the island.

both player and island rotates around the center position.

but after i move the player, the island still rotates around the center just like before, but the player doesn rotate with the island.

it rotates around the center on its own.

why is this happening? :?

Mmmmh, let me see if I understand correctly. Do you have a scene like the diagram below?

           |      |

islandGeom  PlayerGeom

And changing the islandNode would move both the island model and the player... Also, don't forget to call updateGeometricState  on the islandNode after modifying it.

yeah, i have that, but one little difference.

instead of PlayerGeom, i have playerNode. then under playerNode, i have PlayerGeom.

and yes i use baseGame and i update updateGeometricState

Then I have no clue  XD… could you post a minimal code?

duenez said:

Then I have no clue

help~~~ :cry:

i tried to add the worldtranslation change of the island model to both the destination point and the player's localtranslation, but it still doesnt work~

i couldnt get it work with the spatialTransformer, so i just gave up :smiley:

i built my own tranformer, and it works perfectly fine with it now~

thx for the help anyways~ XD

Most strange!  :? Oh, well. I am glad it works now.

duenez said:

Most strange!

I just thought of something… what if you add a second node like so:

            |         |

islandGeom    playerGeom

So that you rotate the island rotation, translate the island translation and then both geometries will be attached to the same transform.

i dont think it will work either.

as long u use spatialTransformer, u can not change the localTranslation of one of the children. coz the localTranslation of a child defines the radius, and if u change it, it will just have a different radius from the island model.

the issue is that the spatialTransformer does not change the child's localtranslation, but worldtranlsation. and in order to move a model under mouse command, u have to change the model's localtranslation which makes it impossible for my purpose. :expressionless: