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 /
avatar image
0
Question by Bluestormy · Feb 04, 2017 at 09:50 AM · troubleshooting

Ball won't move in the Roll-a-Ball tutorial

Hey Guys. I am new to Unity, so apologies if this is very Simple. I have followed the tutorial up to Part 2 of 8, and the ball will not move at all for some reason. I have restarted unity, and deleted the game and made a new one, which, also does not work, and has the same issue. I am perplexed as I have spent a week trying to troubleshoot, but to no avail. My code is verbatim of the tutorials, as it was copy/pasted from the box below. Gravity does work by lifting the player, then beginning the game, which results in it dropping back to rest upon the plane. When I inserted the script into VisualBasic, no errors appeared. However, upon re-opening VisualBasic, a line endings error appeared, which I then pressed the fix button. Here is my code:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour
 {
 
     public float speed;
 
     private Rigidbody rb;
 
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
 
         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
 
         rb.AddForce(movement * speed);
     }
 }

Thank you!

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 Pengocat · Feb 04, 2017 at 04:08 PM 1
Share

Did you set a speed value in the inspector? speed defaults to 0 so "movement * speed(0) = no movement. You can also add Debug.Log("foo") somewhere to check if the code is actually running. The word "foo" would show in the console if it is.

avatar image Bluestormy Pengocat · Feb 05, 2017 at 06:59 AM 0
Share

Hey @Pengocat,how would I go about this? something like speed = 1? Thank you!

avatar image Pengocat Bluestormy · Feb 05, 2017 at 02:56 PM 0
Share

@oStaiko made a good answer.

1 Reply

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

Answer by oStaiko · Feb 05, 2017 at 08:01 AM

Your code is perfect, however Unity has another very important aspect to it, the Inspector. The inspector is something you wont be used to if you have a background in any other simple form of programming, so it's common for new users to get a bit confused. Basically, the inspector allows you to modify public variables in Unity, and even view and change them while the game is running! What you want to do here is go in to your new scene with the ball, click on the ball that has the script attached to it, find the script in the inspector tab, and look for where it says "Speed". You'll notice a box with a 0 in it to the right, and you'll want to change this to any higher number, let's go with 1 for now. If that doesn't fix your issues, post a screenshot of your inspector tab so we can help more.

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 Bluestormy · Feb 07, 2017 at 08:08 AM 0
Share

Thank you very much oStaiko! That fixed it!

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

Unity Constant Crashing 1 Answer

IEnumerator stops working when component slides 1 Answer

my button dosent work, became a light switch instead of a normal button (like a bell) 1 Answer

Trouble opening project from Asset store in Unity 5 (free) 1 Answer

Mobile Button input broken when built for Mac/PC? 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