I have been trying to make a script for some hours, there instantiate a prefab, and then gets the prefab to follow the object, but i hasn’t successes yet.
I have tried many tings, like in update i give it the same coordinates as the object there is moving. And the rotation fucks too
I recently just started scripting, so im still learning, please help.
my script is:
public GameObject Prefab; public GameObject MyShip; void Update() { if (Input.GetKeyDown(KeyCode.B)) { Instantiate(Prefab, MyShip.transform.position, MyShip.transform.rotation); } }
my game is where im a spaceship, and i need to add a gun to the ship. so can you help me making my prefab/gun attached on my object/ship, and have the same rotation (: