I want to place an object in front of the player not matter its rotation. If I get the position of the player and add a z-vector, the obejct is always placed relatively to world coordinates and is consequently not always in front of the player. How can I place an Object relativly to object coordinates?
Thank you for answering!
The easy way to do this is to use Transform.forward which will give you the world space vector for that transforms local z vector.
So… if you do something like…
spawnedTrans.position = playerTrans.position + ( playerTrans.forward * someDistanceFloat );
There’s also Transform.right (X axis) and Transform.up (Yaxis) and the functions Transform.TransformPoint and Transform.TransformVector as well as inverse versions of these that help with transitioning between local and world space.
Check out the documentation. Unity - Scripting API: Transform