I’m trying to use prefabs to instantiate a sprite for a basic shooting setup however MonoDevelop gives me the error:
“The name ‘playerShot’ does not exist in the current context”
Here is my code:
using UnityEngine;
using System.Collections;
public class PlayerControl : ShipClass
{
void Start ()
{
//useless for now
}
void Update ()
{
if (Input.GetButtonDown ("Fire2"))
{
Debug.Log ("Fire2 pressed!");
Instantiate(playerShot);
}
}
}
Where playerShot in this case is the prefab that I have created. I think I’m having trouble getting my head around how a script handles a prefab so any help on this matter would be appreciated. Thanks in advance.
What is the significance of the " " if you don't mind me asking? I found a different way to instantiate but if this works it would be simpler to follow my own code.
– MrZalibUsing quotes signifies the name of an object, while leaving them off would signify an object type. Hope that helps. If my solution works, would you mind clicking accept answer? Thanks!
– JinxologyI don't have time to implement it tonight or tomorrow. I believe you though. I'll let you know what happens! Thanks for the input!
– MrZalib