-3

The script is attached to a coin that when picked does that issue. There is nothing to attach in the inspector.

The CoinMagnet state is assigned to another object (as a magnet).

public void Start()
    {
        Player = GameObject.FindGameObjectWithTag("Player");
        pu = Player.GetComponent<PowerUps>();       
    }

private void Update()
    {

        if (pu.CurrentPowerState == PowerUps.State.CoinMagnet) //issue here
        {
            if (Vector3.Distance(Player.transform.position, transform.position) < CoinMagnetRadius)
           ...
           ...
        }
    }

Here is the Powerups class

public State CurrentPowerState;
 public enum State
    {
        None,
        Invincible,
        CoinMagnet,

    };
Danny
  • 17
  • 4

1 Answers1

2

Well, it seems that your player object does not have a PowerUps component. Attach that script to the player object in your scene and it should work.

Edit: A stack trace about the error or the concrete error message could help resolving the issue.

Alex Barna
  • 46
  • 3