Hi,
I am making a system where by a player in a FPS has a socket parented to their capsule collider which indicates where any weapons this player picks up need to be located.
It then needs to, upon acquisition, snap the weapons mesh onto that socket. However the catch is there is an offset from the meshes transform which is in the form of a socket on each weapon. It is the two sockets (player and weapon) that need to be aligned but the meshes transform that needs to be moved.
This means I need to calculate the meshes new Vector3 position (the rotation and scale are taken care of) based on the location it has to go (the players socket) the location its snapping onto (the weapons socket) and the location of what is actually displayed (the weapon mesh).
I am pretty sure this comes down to differences between local and world space. Does a childed game objects position represent an offset from the parents position?
If so could I just align the meshes transform and the player socket and then create a new Vector3 equal to the meshes position - the sockets position. When my weapon is being attached it will be existing in world space and so the meshes transform will not be childed to anything else.
TLDR: Is a games objects childs transforms position a representation of an offset from the parents position?
just set the transform.localPosittion
– Fattie