Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by TH3HCK3ABL3 · Jul 23, 2013 at 10:22 PM · c#variableclassnoobmethod

Why do I get this error: "Assets/Scripts/Parkour Movement.cs(15,38): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected"

Why do I get this error: "Assets/Scripts/Parkour Movement.cs(15,38): error CS0119: Expression denotes a type', where a variable', value' or method group' was expected" with these lines?:

     private bool surfaceNormal = Vector3;
     private bool myNormal = Vector3;

Thanks for your help. Sorry for such a basic question. I couldn't use new or var because this is under "public class ParkourMovement : MonoBehaviour {"

Thanks again.

EDIT: So after applying the fix below, I know have 28 more errors because my script is a mess after a conversion from Java script. Any help would be greatly appreciated! Thanks!

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent (typeof(CharacterController))]
 public class ParkourMovement : MonoBehaviour {
     public float moveSpeed = 6.0f; // Movement speed
     public float turnSpeed = 90.0f; // Turning speed in degrees per second
     private float lerpSpeed = 10.0f; // Smoothing speed
     public float gravity = 10.0f; // Gravity acceleration
     
     float deltaGround = 0.2f; // Character is grounded up to the distance
     public float jumpSpeed = 10.0f;
     public float jumpRange = 10.0f;
     bool isGrounded;
     private Vector3 surfaceNormal = new Vector3(1,2,3);
     private Vector3 myNormal = Vector3.f;
     private float distGround;
     bool jumping = false; // Flag for jumping to the wall
     private float vertSpeed = 0.0f; // The current speed of the Vertical Jump
     
 
     // Use this for initialization
     void Start () {
         myNormal = Transform.up; // Normal starts as the up direction of the character
         rigidbody.freezeRotation = true; // Disables the rotation via physics
         distGround = collider.bounds.extents.y - collider.center.y; // Distance from transform.posistion to the ground
     }
     
     void FixedUpdate() {
         rigidbody.AddForce (-gravity * rigidbody.mass * myNormal); // Apply constant weight force according to character normal
     }
     
     // Update is called once per frame
     void Update () {
         
         // Jump Code - Jump to wall or simple Jump
         if (jumping) return;
         var ray = Ray;
         var hit = RaycastHit;
         if (Input.GetButtonDown ("Jump")) { // If the player is pressing jump...
             ray = Ray(transform.posistion, transform.forward);
             if (Physics.Raycast(ray, hit, jumpRange)) { // Checks to see if there is a wall
                 JumpToWall(hit.point, hit.normal); // Yes Jump to the wall
             } else {
                 if(isGrounded) { //no; if grounded, jump up
                     Rigidbody.velocity += jumpSpeed * myNormal;
                 }
             }
             
         // Movement Code - Turn left/right with Horizontal Axis
             Transform.Rotate(0, Input.GetAxis ("Horizontal") * turnSpeed * Time.deltaTime, 0); // Update the surface noraml and isGrounded
             ray = Ray(Transform.posistion, -myNormal); // Cast a ray downwards
             if (Physics.Raycast(ray, hit)) {
                 isGrounded = hit.Distance <= distGround + deltaGround;
                 surefaceNoraml = hit.normal;
             } else {
                 isGrounded = false;
                 surfaceNormal = Vector3.up; // Assumes that the noraml is up to avoid some weird shit
             }
             myNormal = Vec.Lerp(myNormal, surfaceNormal, lerpSpeed * Time.deltaTime);
             var myForward = Vector3.Cross (Transform.right, myNormal); // Finds the forwards direction with my normal
             var targetRot = Quaternion.LookRotation (myForward, myNoraml); // Alligns the character to the new myNormal whilst keep the same forward Direction
             Transform.rotation = Quaternion.Lerp (Transform.rotation, targetRot, lerpSpeed * Time.deltaTime);
             Transform.translate (0, 0, Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime);
         }
     }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by clunk47 · Jul 23, 2013 at 11:21 PM

Holy s*** bro lol. There were so many errors, most because of spelling. Some because of capitalization errors. You were also doing some javascript stuff inside this c-sharp script. You are using Monodevelop to program for unity right? If so it has autocomplete... I also organized this where you're not defining a bunch of variables in Update(). I commented out the JumpToWall() statement because you have it calling that method, but the method doesn't exist. Try this out, study how I formatted it, how I rearranged everything. The way I have it makes it way easier for you to find things you want to edit or fix. Here is the error free version of your script.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent (typeof(CharacterController))]
 
 public class ParkourMovement : MonoBehaviour 
 {
     public float moveSpeed = 6.0f; // Movement speed
     public float turnSpeed = 90.0f; // Turning speed in degrees per second
     public float gravity = 10.0f; // Gravity acceleration
     public float jumpSpeed = 10.0f;
     public float jumpRange = 10.0f;
     
     float distGround;
     float lerpSpeed = 10.0f; // Smoothing speed
     float deltaGround = 0.2f; // Character is grounded up to the distance
     float vertSpeed = 0.0f; // The current speed of the Vertical Jump
     
     bool isGrounded;
     bool jumping = false; // Flag for jumping to the wall
     
     Vector3 surfaceNormal = new Vector3(1,2,3);
     Vector3 myNormal = Vector3.forward;
     Vector3 myForward;
     
     Ray ray;
     RaycastHit hit;
     
     Quaternion targetRot;
     
     // Use this for initialization
     void Start () 
     {
         myNormal = transform.up; // Normal starts as the up direction of the character
         rigidbody.freezeRotation = true; // Disables the rotation via physics
         distGround = collider.bounds.extents.y - collider.bounds.center.y; // Distance from transform.posistion to the ground
     }
     
     void FixedUpdate() 
     {
         rigidbody.AddForce (-gravity * rigidbody.mass * myNormal); // Apply constant weight force according to character normal
     }
     
     // Update is called once per frame
     void Update () 
     {
         // Jump Code - Jump to wall or simple Jump
         if (jumping) 
             return;
         
         if (Input.GetButtonDown ("Jump")) 
         { // If the player is pressing jump...
             ray = new Ray(transform.position, transform.forward);
             if (Physics.Raycast(ray, out hit, jumpRange)) 
             { // Checks to see if there is a wall
                 
                 //THERE IS NO METHOD FOR JUMPTOWALL!
                 //JumpToWall(hit.point, hit.normal); // Yes Jump to the wall
             } 
         }
         
         else 
         {
             if(isGrounded) 
             { 
                 //no; if grounded, jump up
                 rigidbody.velocity += jumpSpeed * myNormal;
             }
         }
         
         // Movement Code - Turn left/right with Horizontal Axis
         transform.Rotate(0, Input.GetAxis ("Horizontal") * turnSpeed * Time.deltaTime, 0); // Update the surface noraml and isGrounded
         ray = new Ray(transform.position, -myNormal); // Cast a ray downwards
         
         if (Physics.Raycast(ray, out hit)) 
         {
             isGrounded = hit.distance <= distGround + deltaGround;
             surfaceNormal = hit.normal;
         } 
         
         else 
         {
             isGrounded = false;
             surfaceNormal = Vector3.up; // Assumes that the noraml is up to avoid some weird shit
         }
         
         myNormal = Vector3.Lerp(myNormal, surfaceNormal, lerpSpeed * Time.deltaTime);
         myForward = Vector3.Cross (transform.right, myNormal); // Finds the forwards direction with my normal
         targetRot = Quaternion.LookRotation (myForward, myNormal); // Alligns the character to the new myNormal whilst keep the same forward Direction
         transform.rotation = Quaternion.Lerp (transform.rotation, targetRot, lerpSpeed * Time.deltaTime);
         transform.Translate (0, 0, Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime);
     }
 }
 
Comment
Add comment · Show 2 · Share
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 TH3HCK3ABL3 · Jul 24, 2013 at 12:46 AM 1
Share

Thank you for your reply. Yeah, I know there is a ton of problems with the converting I did myself O.o It's hard to look at Java(Unity)Script and write it as C#. But thank you for the error fixing, really helpful. And yes I am using mono develop and use the autocomplete, but that wasn't much help when I tried to re-write something above my level into a different language. Haha. Thank you again.

avatar image clunk47 · Jul 24, 2013 at 12:51 AM 1
Share

Ahh I see, you were converting. Well, if this helped, please accept and vote up my answer. This will get way easier brotha. I actually started w/ JS as well, and it only took a few weeks to start using C# on a regular basis.

avatar image
0

Answer by Bunny83 · Jul 23, 2013 at 10:25 PM

 private Vector3 surfaceNormal = new Vector3(1,2,3);
 private Vector3 myNormal = Vector3.forward;

The assignments are just sample values ;)

Comment
Add comment · Show 4 · Share
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 TH3HCK3ABL3 · Jul 23, 2013 at 10:35 PM 0
Share

Thanks, however this created more errors:( 28 more. EDIT found*

avatar image gregzo · Jul 23, 2013 at 10:36 PM 0
Share

truth revealed corruption...

avatar image TH3HCK3ABL3 · Jul 23, 2013 at 10:47 PM 0
Share

I agree.

 private float frustrationLevel = 10.0f
avatar image Bunny83 · Jul 23, 2013 at 10:51 PM 1
Share

No, this would not "create" any errors. It just allows the compiler to actually try to compile the rest of your script. The last time it stopped at your surfaceNormal line since it was not valid code. The compiler always reads your scripts from the first line to the last line. Some errors don't stop the compiler and it tries to continue compilation, but if it hits a point where the code is syntactically messed up it can't go on and just breaks out. Once your first errors has been fixed the compiler can actually find the others ;)

$$anonymous$$eep in $$anonymous$$d that it doesn't have to be 28 errors. It's possible that a single mistake can confuse the compiler and cause a lot of errors which actually aren't. Always fix errors from top to bottom!!! Don't try to fix the 9th error because you think that's an easier one.

The best example is a wrong placed quotation marks. This would make the compiler to read your strings as code and your code as strings. It will bash you with tons of errors because all of your text is of course not valid code. Once the quotation marks are fixed everything will be fine ;) (unless there are more actual errors).

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

17 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

Related Questions

Why the variable don't change your value? 1 Answer

How to bind different type of data in an array ? 1 Answer

Parent Class variables in Child Class's Inspector (C#) 0 Answers

Accessing variable from a method in another script and gameObject 2 Answers

Can I access variables of scripts that inherit from abstract classes? 2 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