How do I get rid of these scripting Errors?
the error says: Assets/NewBehaviourScript.cs(26,22): warning CS0219: The variable v' is assigned but its value is never used Assets/NewBehaviourScript.cs(26,22): warning CS0219: The variable
h' is assigned but its value is never used
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float backspeed = 3f;
public float movespeed = 10f;
public float turnspeed = 100f;
public float fallspeed = 100f;
void Update () {
if (Input.GetKey (KeyCode.UpArrow))
transform.Translate (Vector3.forward * Time.deltaTime * movespeed);
if (Input.GetKey (KeyCode.DownArrow))
transform.Translate (-Vector3.forward * Time.deltaTime * movespeed);
if (Input.GetKey (KeyCode.RightArrow))
transform.Rotate (Vector3.up * Time.deltaTime * turnspeed);
if (Input.GetKey (KeyCode.LeftArrow))
transform.Rotate (Vector3.up * Time.deltaTime * -turnspeed);
if (Input.GetKeyDown (KeyCode.Space))
transform.Translate (Vector3.up * Time.deltaTime * fallspeed);
}
void start(){
bool h=Input.GetKey (KeyCode.UpArrow);
bool v=Input.GetKey (KeyCode.DownArrow);
}
void Animating (bool h,bool v)
{
// Create a boolean that is true if either of the input axes is non-zero.
bool walking = h = false;
v = false;
// Tell the animator whether or not the player is walking.
GetComponent<Animator>().SetBool ("IsWalking", walking);
}
}
Answer by allenallenallen · Feb 08, 2016 at 09:24 PM
Those are warnings, not errors. Errors will stop the game from running correctly. Warnings are usually harmless. These two warnings are simply saying that you declared the booleans h and v but you never really used them anywhere.
That said, there are many other actual errors in your code that you didn't provide in your list of errors/warnings. One is an actual error and the others are more like the theories and logic behind the codes.
Line 29 is an error. You should only assign one variable at a time.
What you typed inside Start() are meaningless if you set the booleans to the Up or Down arrow keys ONLY in that specific instant when Start() runs.
Answer by Jessespike · Feb 08, 2016 at 09:26 PM
That's not an error, it's a warning.
It's just saying you created a variable and it's not being used anywhere. Look at the start() function, it's not actually doing anything.