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
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 everything and I've even updated and redownloaded Unity to try and fix this 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 this problem and neither is their friend who tried it too so we're both pretty stuck on this 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 this 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 this for initialization
     void Start () {
         anim = gameObject.GetComponentInChildren<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) -- this 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 think
     I told you to turn it into a bool, so use SetBool. You may also need to add extra
     code that handle your character touching 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 while in midair
         // when you let go of spacebar, and you probably don't want that
         // Goto OnCollisionEnter function to see the other half
     }
     
     //This function reads collisions made in game, specificialy only the frame in which the object just
     //touched another object, hence on enter only.
     void OnCollisionEnter(Collision collisionInfo) {
         foreach (ContactPoint contact in collisionInfo.contacts) { //This just seperates contacts
             if (Vector3.Angle(contact.normal, Vector3.up) < 45) { // This 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 this 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.

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

Survival Shooter Error CS0120 1 Answer

NullReferenceException: Error from the GetStyle() - Method 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