I have a prefab called “Shell”. It has this script attached:
public class ShellExplosion : MonoBehaviour
{ public int sentFromPlayer = 0; } //this is the variable I need to change
I also have a “Player” that has this other script:
public class PlayerScript : MonoBehaviour
{
public Rigidbody m_Shell; // I've put the "shell" prefab here
private void Fire()
{
Rigidbody shellInstance = Instantiate(m_Shell, thisPosition, thisRotation) as Rigidbody;
shellInstance.gameObject.GetComponent<ShellExplosion>().sentFromPlayer=1;
}
}
I get the error ‘ShellExplosion’ does not contain a definition for ‘sentFromPlayer’.
I also tried instantiating as a game object (instead of rigid body), but I get the same error.
I’m sure the names match.
Any help would be appreciated. Thank you