Push object into the direction it is rotated at

So, Im trying to make a bullet. However. I cannot manage to make the bullet fly into the direction it is rotated at. Right now, when I leftclick, it creates a model with position and rotation of the camera. I want this bullet to move along those “axis”. I tried translate or just position changing, but neither worked, since I cannot discover how to make both of them go to the direction of the rotation. Any suggestions?

You can try using a local direction vector:

const speedFactor = 5.0;
const direction = new Three.Vector3();

bullet.getWorldDirection(direction);

bullet.position.add(direction.multiplyScalar(speedFactor));

I know, that this is a really silly question. but, con I somehow pass the direction together with the object? Because everytime I shoot, the bullet is added to an array, then the array is processed in animate(). Im also really unused to the Three.Vector3(), so Im sorry if it is super easy and Im just a dummy

PS: Where from does the Vector3 obtain direction? Im little bit confused

Isn’t the direction of the object equivalent to it’s rotation? (Rotation is calculated and set in object for you, so you can use it to determine the direction every object is facing.)

You set vector to point in the object direction using getWorldDirection method of Object3D.

oh okay Im an idiot. I didnt notice that direction is called in the getWorldDirection :smiley: Thank you, youre a god!

This is little bit weird, but the bullets fly backwards…

If you invert a vector using Vector3.negate - or simply multiply it by a negative speedFactor.