Answer the question
In order to leave comments, you need to log in
How to change the coordinates of an object along its local axis?
Hello, help. For the 2nd day I have been trying to program the spawn of a bullet in front of the edge of the barrel. I calculated what should be the offset from the Transform of the barrel to the Transform of the bullet, let's say it is 5f. I want as soon as I spawn the bullet and give it a rotation equal to the rotation of the barrel, the bullet will move in the direction of the barrel by 5f. I know that something similar can be done with Translate(bullet.forward*speed), but then the bullet will start to FLY in the right direction, and I need it to MOVE 5f along the forward axis.
I tried bullet.position += bullet.TransformPoint(new Vector3(0,0,5f), but the bullet moved in world Z coordinates, not local coordinates. I hope I explained more or less clearly.
Answer the question
In order to leave comments, you need to log in
Everything, Khabrovchane, I understand. I incorrectly used TransformPoint(new Vector3 (0,0,5f)). It was necessary not to add it, but to assign it to bullet.position.
God, why is it so difficult. You create a firePoint object at the place where the bullet should spawn. And in the bullet script you set the movement to it firePoint.transform.right (Looking in which direction the firePoint is looking), but before that, by itself, spawn it on firePoint.transform. position.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question