• 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
0
Question by CraftyMaelyss · Jul 16, 2016 at 12:18 PM · c#unity 5error message

My game script is fine but I'm still getting unexpected class error

I am working on a game in Unity and I've asked someone who is quite experienced who fixed the script for me but I'm still getting these errors. We've done just about everyt$$anonymous$$ng and I've even updated and redownloaded Unity to try and fix t$$anonymous$$s but the script is still showing me errors.

Here's a screenshot of the errors: http://sta.sh/026p1e3f8i5n

I tried writing a new script, typing in exactly what was in the previous script but still received the same errors plus some new ones as well: http://sta.sh/01mxp83amcng

My friend who is helping me isn't experiencing t$$anonymous$$s problem and neither is their friend who tried it too so we're both pretty stuck on t$$anonymous$$s problem. My computer is an MSI all-in-one Gaming touchscreen: http://www.cnet.com/au/products/msi-ag270/ and the system it's using is windows 8.1 My friend is also using windows 8.1 so that can't be the issue.

We would both greatly appreciate any advice about t$$anonymous$$s as we can't figure out what the issue is. Here's a copy of the C# Script:

using UnityEngine; using System.Collections;

public class GamePlayer : MonoBehaviour {

 private Animator anim;
 using UnityEngine;
 using System.Collections;
 
 public class Player : MonoBehaviour {
     
     private Animator anim;
     
     // Use t$$anonymous$$s for initialization
     void Start () {
         anim = gameObject.GetComponentInC$$anonymous$$ldren<Animator> ();
     }
     
     // Update is called once per frame
     void Update () {
         
         if (Input.GetKey ("w")) {
             anim.SetInteger ("AnimPar", 1);
         } else {
             anim.SetInteger ("AnimPar", 0);
         }
         
         
         
         /*if (Input.GetKeyDown ("space")){
         anim.SetInteger ("Jump");
     } else {
         anim.SetInteger ("Jump");
     }*/
         
         /* SetInteger won't work because the function is expecting an integer as the second input value
     In the animator there are different params you can add:
         Integer (int)
         Float
         Boolean (bool)
         Trigger
     Each has their repective functions:
         SetInteger (paramName, int)
         SetFloat (paramName, float)
         SetBool (paramName, bool)
         SetTrigger (paramName) -- t$$anonymous$$s one has no second input
     More animator functions: https://docs.unity3d.com/ScriptReference/Animator.html
     
     You had it right, just you forgot to change the name of the function. But I t$$anonymous$$nk
     I told you to turn it into a bool, so use SetBool. You may also need to add extra
     code that handle your character touc$$anonymous$$ng the ground so that the jump can end.
     */
         
         if (Input.GetKeyDown ("space")){
             anim.SetBool ("Jump", true);
         } // notice how i didn't add the second half of your original snippet
         // If i left it, then your character would have transistioned to standing w$$anonymous$$le in midair
         // when you let go of spacebar, and you probably don't want that
         // Goto OnCollisionEnter function to see the other half
     }
     
     //T$$anonymous$$s function reads collisions made in game, specificialy only the frame in w$$anonymous$$ch the object just
     //touched another object, hence on enter only.
     void OnCollisionEnter(Collision collisionInfo) {
         foreach (ContactPoint contact in collisionInfo.contacts) { //T$$anonymous$$s just seperates contacts
             if (Vector3.Angle(contact.normal, Vector3.up) < 45) { // T$$anonymous$$s if statement checks if the platform it collided with is flat enough to stand on
                 // platforms that are less than a 45 degree angle incline will not let t$$anonymous$$s part of the code run
                 anim.SetBool ("Jump", false); // If it is a "floor" then the jump animation will stop.
             }
         }
     }
     
     // make sure you have the transisions:
     // Idle => Jump (Condition: "Jump" == true)
     // Jump => Idle (Condition: "Jump" == false)
 }
Comment
Add comment
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

207 People are following this question.

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

Related Questions

Brackeys Multiplayer fps tutorials trouble.. 0 Answers

Error: -Has an extra field and can't be serialized 1 Answer

Unable to join player connection alternative multicast group. 1 Answer

NullReferenceException: Error from the GetStyle() - Method 1 Answer

[Help] I keep getting an error with blank message when I create a C# script. 3 Answers


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