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 Chrispy7502 · Oct 04, 2016 at 10:38 PM · scripting problemroll a ball

help with roll a ball scripting

if someone would be kind enough to post the corect script for the roll a ball tutorial because the one that is given in the tutorial dosnt seem to work

Comment
Add comment · Show 4
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 Zitoox · Oct 05, 2016 at 02:58 AM 0
Share

I have never seen that tutorial... Are you talking about the RollerBall? And what problems are you having??

avatar image Chrispy7502 · Oct 05, 2016 at 11:41 AM 0
Share

@Zitoox I am talking about the roll a ball tutorial on there website and when I put the correct script in it says there is a compile error and in the console it says the referenced script on this behavior (game object player) is missing and I don't know what to do

avatar image Zitoox Chrispy7502 · Oct 05, 2016 at 11:25 PM 0
Share

Do the script have a variable in wich you need to drag the character? $$anonymous$$aybe the problem is that. You could also try to tag your character as Player or just rename it to player.

avatar image arezendes · Jan 21, 2017 at 03:21 AM 0
Share

I'm having the same problem. I'm on a $$anonymous$$ac running Unity 5.5.0f3 Personal. Checked my code and it seems exactly the same as the second video, yet it doesn't do anything and I get the same errors as Chrispy7502 described. Sure, I could copy the code – but I want to know what happened so that I can avoid the error in the future. Could it be that the tutorial is only checked with version 5? Doubtful, but I thought I'd ask. Here's what I have: using UnityEngine; using System.Collections;

 public class PlayerController : $$anonymous$$onoBehaviour {
 
     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);
     }
 
 }
 

I can't seem to get it to work.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Chrispy7502 · Oct 06, 2016 at 07:51 AM

@Zitoox I don't want to drag the player I want to use certain keys to move it but it doesn't clarify which keys it's supposed to use and the ball is already named player

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
avatar image
0

Answer by JScotty · Oct 06, 2016 at 09:09 AM

 [RequireComponent(typeof(Rigidbody))]
 public class PlayerController : MonoBehaviour {
 
     public float speed = 5.0f;
 
     private Rigidbody body;
 
     void Start () {
         body = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate (){
         float moveHorizontal = Input.GetAxis ("Horizontal");
         float moveVertical = Input.GetAxis ("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         body.AddForce (movement * speed);
     }
 }
 
 
 //or 
 
 
 
 
 [RequireComponent(typeof(Rigidbody))]
 public class PlayerController : MonoBehaviour {
 
     public float speed = 5.0f;
 
     private Rigidbody body;
 
     void Start () {
         body = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate () {
         float moveHorizontal = 0;
         float moveVertical = 0;
 
        if(Input.GetButtonDown(KeyCode.A)) // if keybutton down
                moveHorizontal = -1;
        else if(Input.GetButtonDown(KeyCode.D)) // if keybutton down
                moveHorizontal = 1;
 
        if(Input.GetButtonDown(KeyCode.S)) // if keybutton down
                moveVertical = -1;
        else if(Input.GetButtonDown(KeyCode.W)) // if keybutton down
                moveVertical = 1;
         
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
         body.AddForce (movement * speed);
     }
 }

Hope this helps you out a bit

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
avatar image
0

Answer by arezendes · Jan 21, 2017 at 06:52 AM

@jScotty Neither of those solutions worked for 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

Character triple+ Jumping: Please Help! 0 Answers

Roll a Ball wont roll? 1 Answer

I copied all the code in my script for the Roll a Ball tutorial to make the camera follow the ball, but the camera is still not following the ball? (It says no code errors) 2 Answers

Roll a Ball Tutorial problem 1 Answer

i was following the roll a ball tutorial and in the script component it says there is a compile error and it says the reference script on this behavior is missing i dont know what to do 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