Error CS0246 help please
Script: using UnityEngine; using System.Collections;
public class Player : MovingObject {
public float restartLevelDelay = 1f;
public int pointsPerFood = 10;
public int pointsPerSoda = 20;
public int wallDamage = 1;
private Animator animator;
private int food;
protected override void Start ()
{
animator = GetComponent<Animator>();
food = GameManager.instance.playerFoodPoints;
base.Start ();
}
private void OnDisable ()
{
GameManager.instance.playerFoodPoints = food;
}
private void Update ()
{
if(!GameManager.instance.playersTurn) return;
int horizontal = 0;
int vertical = 0;
horizontal = (int) (Input.GetAxisRaw ("Horizontal"));
vertical = (int) (Input.GetAxisRaw ("Vertical"));
if(horizontal != 0)
{
vertical = 0;
}
if(horizontal != 0 || vertical != 0)
{
AttemptMove<Wall> (horizontal, vertical);
}
}
protected override void AttemptMove <T> (int xDir, int yDir)
{
food--;
base.AttemptMove <T> (xDir, yDir);
RaycastHit2D hit;
if (Move (xDir, yDir, out hit))
{
//Call RandomizeSfx of SoundManager to play the move sound, passing in two audio clips to choose from.
}
CheckIfGameOver ();
GameManager.instance.playersTurn = false;
}
protected override void OnCantMove <T> (T component)
{
Wall hitWall = component as Wall;
hitWall.DamageWall (wallDamage);
animator.SetTrigger ("playerChop");
}
private void OnTriggerEnter2D (Collider2D other)
{
if(other.tag == "Exit")
{
Invoke ("Restart", restartLevelDelay);
enabled = false;
}
else if(other.tag == "Food")
{
food += pointsPerFood;
other.gameObject.SetActive (false);
}
else if(other.tag == "Soda")
{
food += pointsPerSoda;
other.gameObject.SetActive (false);
}
}
private void Restart ()
{
Application.LoadLevel (Application.loadedLevel);
}
public void LoseFood (int loss)
{
animator.SetTrigger ("playerHit");
food -= loss;
CheckIfGameOver ();
}
private void CheckIfGameOver ()
{
if (food <= 0)
{
GameManager.instance.GameOver ();
}
}
}
Error: Assets/S&S&S/Scripts/GameManager.cs(5,31): error CS0246: The type or namespace name `MovingObject' could not be found. Are you missing a using directive or an assembly reference?
do you have another class called $$anonymous$$ovingObject
? maybe that isn't compiling properly...
Your error is in the class Game$$anonymous$$anager, so you should probably post that one.
You can get this error if those two classes are not in the same namespace and you are missing a using directive.
$$anonymous$$oved to the HelpRoom. Please take the time and read the user guide.
Also have a look at the FAQs, especially the section "Why did my question get closed or rejected?".
And don't forget to read the sticky post in the helproom
Your answer
Follow this Question
Related Questions
How to instantiate my ScriptableObject on Scenario 1 Answer
Static Assets Not Working,... 0 Answers
How to access .asset file via c#? (Post-processing) 0 Answers
Unable to Add script to an object 1 Answer
Randomation Vehicle Physics 2.0 HELP 1 Answer