I have a script that launches a bullet in any direction, this sets the bullet gameobject to face the current direction. However, since I’m making a top down 2d game, i need to have a “wallCollider” 1 unit below in Y-axis, and it needs to be a child of the bullet gameobject.
It works fine if I fire right (see image 1), but when the gameobject gets rotated the wallCollider as a child of course rotates along with it (image 2).
How can I find the local position for the child, after it’s been rotated? (Image 3)
I guess the localRotation should be 45 if the bullet is rotated -45 like the image below.
I’ve tried something like this, but it doesn’t work at all and sets the wall colider to 46,0.3,0:
var worldPosition = transform.InverseTransformPoint(new Vector3(0,-1,0));
wallCollider.localPosition = wallCollider.TransformPoint(worldPosition);
How do I solve this? Thank you in advance! ![]()
