Whats wrong with this "lerpMultiplier = 0.02f;"?
So im going to develop my own games an im new to this. I bought a book that's been teaching me how to create games and im in a coding section of the book. It ask me to make a script with a code on it that is not working, i copied the code exactly how it is in the book but "lerpMultiplier = 0.02f;" there's a problem with this part, i've tried to look for some answers but i haven't found any, can anyone help me? this is the whole script in the book.
using System.Collections; using UnityEngine;
using UnityEngine.UI;
public class SplashScreen : MonoBehaviour { public Image logo; Color logoColor; public lerpMultiplier = 0.02f;
void Start ()
{
logoColor = new Color (1, 1, 1, 0);
logo.color = logoColor;
StartCoroutine (GotoMainMenu());
}
IEnumerator GotoMainMenu()
{
yield return new WaitForSeconds(4);
Application.LoadLevel ("MainMenu");
}
void Update ()
{
logoColor = Color.Lerp(logoColor, new Color(1, 1, 1),
Time.time * lerpMultiplier);
logo.color = logoColor;
}
Answer by Bunny83 · Mar 21, 2018 at 01:21 AM
To declare a variable / field you have to specify a type. The general syntax is
[modifiers] TYPE NAME [= init value];
Things in square brackets are optional.
In your case you want to declare a float variable like this:
public float lerpMultiplier = 0.02f;
Your answer
Follow this Question
Related Questions
Setting max speed of spacecraft 1 Answer
ParticleSystem.Emit Deprecated? 1 Answer
I just can't get RequiredComponent to work 2 Answers
Add items from array to another array by parameter value 0 Answers
Declaring Array, HELP. 1 Answer