Hello guys.
I am making a space ship shooter game.
I have one problem. Mainly:
- I have player ship Game Object and a script assigned to it holding the PlayerBullet Game Object
- Now whenever player touches swap game object (CollisionEnter) I want the PlayerBullet Game Object to become another bullet from my prefabs.
Here is part of code:
public class PlayerControls : MonoBehaviour {
public GameObject PlayerBulletGO; // my starting bullet - assigned to me in Unity via script
}
//then I want it to switch here:
void OnTriggerEnter2D(Collider2D col)
{
if(col.tag == “GreenWeaponTag”)
{
PlayerBulletGO = GameObject.Find(“GreenWeapon”);
}
}
Not working how I want - do my green weapon gameobject need to be in scene?
Any ideas?
Thanks