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 dqflynn · Mar 09, 2014 at 07:45 PM · tutorialroll a ball

Can't follow "roll a ball" tutorial. No cube rotate or GUI count.

Even though it seems I'm following the scripts perfectly, (and I've looked it over at LEAST twice) it keeps not working. Specifically, I can't get my cubes to rotate and my GUI text to count my cubes. And when I delete the "troublesome" code that the error messages tell me aren't right, it just seems to make more errors. If anyone could try to help correct me, that would be great. THANKS!

Comment
Add comment · Show 10
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 robertbu · Mar 09, 2014 at 07:51 PM 1
Share

Please post your script and someone can help you figure out compile or logic errors.

avatar image dqflynn · Mar 09, 2014 at 08:00 PM 0
Share

using UnityEngine; using System.Collections;

public class playercont : $$anonymous$$onoBehaviour { public float speed; public GUIText countText private int count;

 void Start ()
 {
             count = 0;
     setCountText ();
     }

 void FixedUpdate ()
 {
             float moveHorizontal = Input.GetAxis ("Horizontal");
             float moveVertical = Input.GetAxis ("Vertical");

             Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
 
             rigidbody.AddForce (movement * speed * Time.deltaTime);
     }

 void OnTriggerEnter (Collider other) 
 {
     if(other.gameObject.tag == "pickup")
     {
         other.gameObject.SetActive(false);
     count = count + 1;
     setCountText ();
     }
 {

     void setCountText ();
     }
     {
         countText.text = "count: " + count.ToString ();
     }

there's my script for my player controller. Here's my rotating cube script: using UnityEngine; using System.Collections;

public class Rotatah : $$anonymous$$onoBehaviour {

 void update ()
 {
     transform.Rotate (new Vector3(15, 30, 45) * Time.deltaTime);
 }

}

if you can Identify my mistakes, that would be great. The Count one is the most important one, I think.

avatar image dqflynn · Mar 09, 2014 at 08:01 PM 0
Share

oh, and on "using UnityEngine; using System.Collections;" they ARE separate lines.

avatar image Destran · Mar 09, 2014 at 08:04 PM 1
Share

You never declare the count variable if I'm reading this right. I'll watch the video and post the script in one sec

avatar image fifthknotch · Mar 09, 2014 at 08:05 PM 0
Share

What is the error and on what line?

Show more comments

2 Replies

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

Answer by Destran · Mar 09, 2014 at 08:20 PM

Here's the PlayerController script from the tutorial:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour
 {
     public GUIText countText;
     public GUIText winText;
     private int count;
     public float speed;
 
     void Start ()
     {
         count = 0;
         SetCountText ();
         winText.text = "";
     }
         
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
 
         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
 
         rigidbody.AddForce(movement * speed * Time.deltaTime);
     }
 
     void OnTriggerEnter(Collider other)
     {
         if(other.gameObject.tag == "PickUp")
         {
             other.gameObject.SetActive(false);
             count = count+1;
             SetCountText();
         }
     }
     void SetCountText()
     {
         countText.text = "Count: " + count.ToString();
         if(count >= 12)
         {
             winText.text = "You Win";
         }
 
 
     }
 
 }

Your rotating cube script isn't correct because "update" needs to be "Update"

like so:

 function Update () {
     transform.Rotate(new Vector3(15,30,45) * Time.deltaTime);
 }

If adding these scripts in doesn't fix it, it's probably not a scripting problem and more likely you set something up incorrectly, try starting the tutorial over. It's pretty short so hopefully starting over won't be a total bummer.

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 dqflynn · Mar 09, 2014 at 08:36 PM 0
Share

that fixes my rotating problem, thanks. I'd up rate it thumbs up, but I'm new so I have no reputation haha.

avatar image Destran · Mar 09, 2014 at 08:45 PM 1
Share

No problem :D Stoked I could help

avatar image fifthknotch · Mar 09, 2014 at 08:51 PM 1
Share

Be sure to mark it as correct (little green check), and I thumbs uppedhis answer and thumbs upped your question so you now have enough to thumbs up his answer yourself

avatar image dqflynn · Mar 09, 2014 at 08:58 PM 0
Share

O$$anonymous$$, it all worked. Thanks for helping me out, now I can go on without worrying about "what did I do wrong?, how did my game get messed up?", thanks a lot!

avatar image
0

Answer by fifthknotch · Mar 09, 2014 at 08:39 PM

Found both issues : function update needs to be function Update as @Destran pointed out.

Also, this section of your script has an unneeded } at the beginning. Hope this solved your problem.

  void setCountText ();
     }
     {
        countText.text = "count: " + count.ToString ();
     }

 
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

22 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

Related Questions

How do i put lights with muzzleflash? 1 Answer

Csharp Script won't open - Roll-a-ball tutorial 1 Answer

Script not working 0 Answers

Roll-A-Ball Tutorial: Ball moves on its own 3 Answers

Burg Zerg Arcade Tutorial Help 3 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