I am referencing a script from another object. I am using the FindObjectOfType(); and of course the object is ScoreManager. Yet, I get a does not exist error in connection with the float that I am trying to work with.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using system;
public class PowerupsManager : MonoBehaviour {
private bool doublePoints;
private bool safeMode;
private bool powerupActive;
private float powerupLengthCounter;
private ScoreManager theScoreManager;
// Use this for initialization
void Start () {
theScoreManager = FindObjectOfType<ScoreManager>();
}
// Update is called once per frame
void Update () {
if(powerupActive)
{
powerupLengthCounter -= Time.deltaTime;
if(doublePoints)
{
theScoreManager.pointsPerSecond = normalPointsPerSecond * 2;
}
if(powerupLengthCounter <= 0)
{
theScoreManager.pointsPerSecond = normalPointsPerSecond;
powerupActive = false;
}
}
}
public void ActivatePowerup(bool points, bool safe, float time)
{
doublePoints = points;
//safeMode = safe;
powerupLengthCounter = time;
normalPointsPerSecond = theScoreManager.pointsPerSecond;
powerupActive = true;
}
}