2D Shooter: Fixing Offset Issues
So we got our spaceship, it can shoot lasers, and when we have a powerup activated, it will shoot three at once!
Then when we test it out, we might see something like this:
If you look closely, the lasers are just slightly off from where they need to be, even though we positioned them right when we created the prefab.
Or it could be more noticeable like this:
There are number of things that could cause these things to happen. One, when we made the prefab, we forgot to check the z-axis. This would be case in the first example, where the lasers appear offset because they are actually spawning farther away. What if you made sure the lasers were set to 0 on the z-axis? Well I will explain.
It could also be similar to the second example, where the coordinates of the lasers are affected by the coordinate of the parent object they’re sorted under. This is because the parent created its own system of local coordinates, so if the parent is located at (2,4,7), that would act as the center (0,0,0) for any of its children. So in either case, check the position of the empty parent object, and make sure it is set to (0,0,0) so it matches globally.
If none of this works, you might have to resort to repositioning the lasers themselves until they get to how you want it to look. You can also try restarting Unity and see if that helps, or try toggling the global/local button when positioning.
Anyways, hopefully this helps, and you get your triple-shot to look like this: