- Home /
Get axis of bullet for rigidbody.velocity
Hello,
my script creates a bullet instatiate at the position of the player and in the direction of the ray. so far it works but when i come to the part where i give the rigidbody of the bullet a transformdirection with vector3 it always takes the local axis of the player and NOT the Z - axis of the bullet which would be the correct axis.
how am i able to get the axis of the bullet to take for rigidbody.velocity?
GameObject instaBullet = Instantiate(bullet, transform.position,Quaternion.LookRotation(ray.direction)) as GameObject;
Rigidbody instBulletRigidbody = instaBullet.GetComponent<Rigidbody>();
instBulletRigidbody.velocity = transform.TransformDirection(Vector3.forward*10);
Answer by unity_ek98vnTRplGj8Q · May 20, 2020 at 09:40 PM
Try instBulletRigidbody.velocity = instaBullet .transform.TransformDirection(Vector3.forward*10);
Your answer
Follow this Question
Related Questions
remove forward component from velocity vector 2 Answers
Gravity doesn't work 2 Answers
Movement behaves differently on X axis 0 Answers
Mimic Gravity Movement Via Setting Velocity 0 Answers
How do I obtain the local velocity of a Rigid body on one axis? 3 Answers