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
1
Question by Gypsy1 · Feb 07, 2015 at 06:46 PM · roll a ball

Roll-a-Ball project error trying to AddForce

Hi Everyone. I am doing the Roll-a-Ball tutorial and am stuck early on. I am on lesson 3 here: http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player

Below is my C# code, which is literally the SAME as the one in tutorial video, but I keep getting the "Expression denotes a type where a variable, value or method group was expected" error when I hit save. There are 3 errors all on the last line.

I browsed similar error questions but those were unable to help. Thanks!

     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         rigidbody.AddForce(movement);
     }
 }
Comment
Add comment · Show 5
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 AngryBurritoCoder · Feb 07, 2015 at 06:59 PM 0
Share

you can double click on the error and it highlights the error in the script, most of the times

avatar image Gypsy1 · Feb 07, 2015 at 07:07 PM 0
Share

thanks. so i quit monodevelop and restarted, and the errors disappeared (they were on line 8) the code is not showing up in my inspector though. when i click "open" it takes me to this code in monodevelop how do i make it show in inspector?

avatar image Mmmpies · Feb 07, 2015 at 07:09 PM 0
Share

Just try clicking play if the error has gone.

avatar image AngryBurritoCoder · Feb 07, 2015 at 07:10 PM 0
Share

you can only see code in unity when you click on the actual script file in project hierarchy, but you cant edit it from unity itself

avatar image Gypsy1 · Feb 07, 2015 at 07:19 PM 0
Share

ok guys so i restarted Unity as well. and the code showed up in inspector and play works / ball moves.

THAN$$anonymous$$S

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mmmpies · Feb 07, 2015 at 07:02 PM

Odd Your script works perfectly, I just created that scene with this full script (using statements included)

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour {
 
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
         
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
         
         rigidbody.AddForce(movement);
     }
 }
 
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 AngryBurritoCoder · Feb 07, 2015 at 07:04 PM 0
Share

im pretty sure something else in his script causes problems, maybe variables in there declared

avatar image Mmmpies · Feb 07, 2015 at 07:06 PM 0
Share

Yeah but I copied and pasted the code from the question, so only the headers left or something outside the code.

avatar image Gypsy1 · Feb 08, 2015 at 02:28 AM 0
Share

thanks mmmpies.

as i said in the comment above i restarted monodevelop and the errors disappeared.

the code is not showing up in the Inspector though? when i click on open it takes me to monodevelop but how do i make it appear in inspector?

avatar image Mmmpies · Feb 08, 2015 at 09:06 AM 0
Share

Sorry @Gypsy1 was night time where I am. If you click on the script in assets (probably in a scripts folder) you can see the file in the inspector but its not a good way of viewing scripts. Better to double click and let mono open it.

If you have public variables in a script and you've dragged the script onto an object in the hierarchy you can also play the game with $$anonymous$$aximizeOnPlay unselected and then select the object in the hierarchy. That way you can see the variables value whilst playing, very handy for debugging.

But that script is fine, I suspect Unity/$$anonymous$$ono had a $$anonymous$$or memory glitch. If it keeps happening first try reinstalling Unity, if it continues after that get some memory testing software but for a one off I wouldn't worry about it.

Sorry for any typo's typing on my phone.

avatar image
0

Answer by XRuinX · Mar 06, 2015 at 03:34 PM

I just had this same problem..... I've searched for the past hour and a half before coming to find out that simply restarting Unity would fix the problem. I was getting error CS0120 regarding rigidbody.addforce and was sure it was my code but I had made 0 changes to it and it fixed itself on restart. lol oh well, hopefully others stumble across this page, even as closure so they'll know the quick fix next time (after a good look at the code that it:D )

Comment
Add comment · Show 1 · 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 meat5000 ♦ · Mar 06, 2015 at 03:36 PM 0
Share

In Unity 5 I added a small upward impulse force to a cube for 1 single frame.

This caused the cube to rocket into space and it was accelerating exponentially.

Fixed on restart!

avatar image
0

Answer by Sefat · Nov 22, 2016 at 09:07 AM

I do same as in the video but i got the same problem it shows one error on AddFoce I am new in unity so some one help me....

Comment
Add comment · 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

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

labyrinth like game 1 Answer

Error on Roll a Ball script Assets/scripts/playercontroller.cs(26,1): error CS8025: Parsing error 1 Answer

Potholes to roll the ball 0 Answers

why is my sphere reddish 1 Answer

Virtual joystick for roll a ball game 0 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