…but not getting expected return value.
I think this video helped my issue with creating a multiplier attached to the Block script to communicate with the score keeper. I had initially over-complicated the method by passing parameters back and forth when I just needed to return the multiplier by itself.
However, no matter what I enter in the Serialize Field for “float multiplier,” it returns as 1 according to the Debug.Log I set up in my GetMultiplier() method on the Block script. I even tried hard-coding the multiplier to 10f and it returns 1.
In Block.cs:
[SerializeField] float multiplier;
...
...
public float GetMultipler()
{
Debug.Log(multiplier);
return multiplier;
}
And in GameStatus.cs:
...
...
public void AddToScore()
{
currentScore = currentScore + (pointsPerBlock * block.GetMultiplier())
}
So, my guess as to why this is happening is because when I use FindObjectOfType, the method is deriving the multiplier from the first block it finds and not on each particular block that’s being destroyed and adding to the score.
If that is the case I might need to derive a new scorekeeping methodology to track it.