How to make a vector 3 create an object at a transform?

I need to make a gameObject (that behaves like a bullet) where the player is looking and it only moves at one of the rotations due to that fact that I’m stuck on having it move at vector3.forward, but instead I need to use the transform’s direction instead of just making the gameObject go forward. (pls help!)

For this case exactly Unity already offers a function which does this for you for the default axis vectors forward, up and side;

It is called:


So in your case setting the velocity to

  sbObject.GetComponent<Rigidbody>().velocity = transform.forward*sPEEDISKEY;

should be the easier formulation.

However in general it should do the same thing as what you are already doing correctly with TransformDirection.

If this is not doing the correct thing make sure that you are actually on the correct object.
transform will refer to the Transform of the Object that your script is on. If that is not rotated in the correct direction then the snowball will also always fly in the wrong one.

Are you perhaps only rotating your camera? Because you use the rotation and position of the camera as spawn parameters for the snowball? In that case you’d need


as direction

Next time:
please post the code using the formatting tool and don’t post screenshots of code.

Please make your post 3 sentences instead of one really really really long one that i have to read 3 times but still am not sure what exactly you are saying.

Let me know if that helped, good luck.