How do I make character pick up object to front of him?
I have 3rd person game, which has character who picks up object with left mouse button and drops it when I click object again. This works fine.
I am using parenting to do this. My problem is, when I pick up object, it won't be in front of the character.
I have tried
player.transform.position.z + 1f;
and
player.transform.parent.position.forward + 1f;
z one works, kinda. When character is facing "north" it will place object frotn of him, but if he faces any other direction it will be on his side/back. parent.position.forward doesn't do anything and just position.forward places it near world 0.0.0.
How do I detect which way my character is facing and then place object in front of him when I pick it up?
Answer by rockyourteeth · Oct 13, 2015 at 03:22 AM
Try using "local position" instead of position. Regular "position" will place an object at a position in the world. As in, (0, 0, 0) would be in the middle of the world. But local position is relative to the object transform. So, (0, 0, 0) will always be in the middle of the object, and any offsets will be from there.