Hi everyone i’m making a fighter aircraft and i need to make bombs but all the current scripts are for spawning an object at a certain position.
I can easily place a rigidbody on the bombs to make it fall and use ontriggerenter to destroy the bomb and make an explosion but how do i spawn an object at the player’s current position by pressing “B”?
Hi, you should use something like this:
public GameObject Bomb;
public GameObject Player;
void Start()
{
Player = GameObject.Find("Player");
}
void Update()
{
if (Input.GetKeyDown("b"))
{
Instantiate(Bomb, Player.transform.position, Quaternion.identity);
}
}