Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
-1
Question by Mafflouki · Aug 25, 2016 at 08:27 PM · c#asset

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?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gjf · Aug 25, 2016 at 01:43 PM 1
Share

do you have another class called $$anonymous$$ovingObject? maybe that isn't compiling properly...

avatar image ScaniX · Aug 25, 2016 at 08:33 PM 0
Share

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.

avatar image Bunny83 · Aug 25, 2016 at 11:29 PM 0
Share

$$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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges