Hello,
I am doing the scripting unity lessons. On the if statements chapter I get this code from the lesson.
I copy the script below in Microsoft Visual Studio and attach it to a cube in Unity.
But nothing prints in the console(I press space plenty).
The lesson does not say how to test it myslef.
Can anyone adivse?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class coffee : MonoBehaviour
{
float coffeeTemperature = 85.0f;
float hotLimitTemperature = 70.0f;
float coldLimitTemperature = 40.0f;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
TemperatureTest();
coffeeTemperature -= Time.deltaTime * 5f;
}
void TemperatureTest()
{
// If the coffee's temperature is greater than the hottest drinking temperature...
if (coffeeTemperature > hotLimitTemperature)
{
// ... do this.
print("Coffee is too hot.");
}
// If it isn't, but the coffee temperature is less than the coldest drinking temperature...
else if (coffeeTemperature < coldLimitTemperature)
{
// ... do this.
print("Coffee is too cold.");
}
// If it is neither of those then...
else
{
// ... do this.
print("Coffee is just right.");
}
}
}