#3D snapping points issues

1 messages · Page 1 of 1 (latest)

pseudo blade
#

So, i'm making a game about building stuff in TotK fashion. I have rigidbodies, that have Node3D as children to represent snapping points. When i bring two snapping points close enough, i set the position of one rigidbody so its snap point is at the exact same place as the other rigidbody's. I managed to make this part work.

I also want to set the rotation of the rigidbody so its snap point's forward vector is aligned with the opposite of the other snap point forward vector. And this is not working as expected, as rotations are a bit trickier than positions... Any help would be appreciated 🙂

this is when the snapping points are already correctly aligned, i just have to move the object

#

and this is where i'm stuck : i don't know how i should rotate the rigidbody so that the snapping points are aligned

viral token
#

You could set a var on each object that can be snapped, and that's the vector with the data on how its snapped child should be aligned/rotated?

#

A potential alternative would be getting the normal of the snapped surface/position? So it's a bit less manual work but more code, but its smarter.

#

Could be an issue for potential future different shapes/angles, etc..

#

Getting the normal vector from the snapping surface is the cleanest, but it has the assumption that each snapping surface will be flat where objects snap perpendicular. But hey, in your example above it should work.

pseudo blade
#

The snapping point is a node3d and I set it up so its forward vector is the normal

#

I suppose I have to get the global_rotation of the other snapping point, then set the global_rotation of my rigidbody to align its snapping point... But nothing I tried worked

viral token
#

Yes.

#

But you can take one as basis (the parent/boss/whatever), and then then see if the other one is the same, except flipped (and/or rotated correctly)

pseudo blade
#

i've been thinking about it the whole day, and still can't wrap my head around it

#

i've tried many things but i don't really understand what i'm doing