- Home /
How can I get bullets to change direction when using Photon.Instantiate()?
Here's the code thats giving me trouble:
Gameobject clone = (Gameobject)PhotonNetwork.Instantiate("projectile", transform.position, transform.rotation);
clone.rigidbody.velocity = Vector3.forward * projectilespeed;
This bit of code is attached to an empty gameobject called "hand". The character is structured like this: Character>Main Camera> Hand. When I spawn a projectile, it does not face my current rotation.For example, I will turn my character to the left or right, but the bullets always travel along the z- axis. They should follow my rotation, like bullets coming out of the barrel of the gun that I am holding. I don't know what I am doing wrong. Can someone please assist me with this issue? Thank you.
Your answer
Follow this Question
Related Questions
PhotonNetworkConnectManually Error 1 Answer
[PUN] Why is my Photon script not working? Help! 1 Answer
Photon PUN offline mode didn't work 2 Answers
Photon RPC problem... 3 Answers
Unity photon network - game room 1 Answer