Search Unity

Official Roll-a-ball Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Apr 17, 2015.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    When posting code on the forums, you must use code tags.

    Please learn to use code tags properly: http://forum.unity3d.com/threads/using-code-tags-properly.143875/


     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    What is the name of the script that you have chosen?

    Does the script name match the class name?

    eg: Is the script called "CameraController.cs"?

    You can an error somewhere in your code that prevents compilation. Until you fix the error.

    Can you include the full error log here?

     
  3. SOMEONEONTHEBLOCK

    SOMEONEONTHEBLOCK

    Joined:
    Apr 19, 2017
    Posts:
    2

    so I did change that and it worked thanks dude.

    Max
     
  4. jhirsh

    jhirsh

    Joined:
    Apr 16, 2017
    Posts:
    2
    Pickups aren't working after I build the exe

    I just finished the roll a ball tutorial. All was well until I went through the build process.

    The game works as anticipated in the editor (play) function, but when i build it; the "pickup object" script doesn't seem to be running or trigger collision is not working properly. The ball rolls through the pickups without deactivating the pickup and the UI is not updated.

    What I have tried: I have built several times with for windows 32 & 64 bit with the same result. I tried full screen and windowed mode thinking the collision position may not be in sync with the render.
    I have checked both output_logs and see no obvious issues.
    I'm using Unity 5.6.0f3 Personal (64bit).

    Thank you in advance for your assistance

    -Jordan

    P.S. The potentially offending script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class PlayerController : MonoBehaviour
    7. {
    8.     public float GroundSpeed;
    9.     public float AirSpeed;
    10.     public float jumpImpulse;
    11.  
    12.     public Text countText;
    13.     public Text winText;
    14.  
    15.     private Rigidbody rb;
    16.     private Vector3 resetPosition = new Vector3(0, 10, 0);
    17.     private int count;
    18.  
    19.     private void Start()
    20.     {
    21.         count = 0;
    22.         SetCountText();
    23.         rb = GetComponent<Rigidbody>();
    24.         winText.text = "";
    25.     }
    26.  
    27.     private void FixedUpdate()
    28.     {
    29.         float moveHorizontal = Input.GetAxis("Horizontal");
    30.         float moveVertical = Input.GetAxis("Vertical");
    31.         float jump = Input.GetAxis("Jump");
    32.        
    33.         if ( transform.position[1] == 0.5)
    34.         {
    35.             jump *= jumpImpulse;
    36.             moveHorizontal *= GroundSpeed;
    37.             moveVertical *= GroundSpeed;
    38.         }
    39.         else
    40.         {
    41.             jump = 0;
    42.             moveHorizontal *= AirSpeed;
    43.             moveVertical *= AirSpeed;
    44.         }
    45.  
    46.         if (transform.position[1] < -2)
    47.             transform.position = resetPosition;
    48.  
    49.         Vector3 movement = new Vector3(moveHorizontal, jump, moveVertical);
    50.  
    51.         rb.AddForce(movement);
    52.     }
    53.  
    54.     private void OnTriggerEnter(Collider other)
    55.     {
    56.         if (other.gameObject.CompareTag("PickUp"))
    57.         {
    58.             other.gameObject.SetActive(false);
    59.             count++;
    60.             SetCountText();
    61.         }
    62.     }
    63.  
    64.     void SetCountText()
    65.     {
    66.         countText.text = "Count: " + count.ToString();
    67.  
    68.         if (count >= 9)
    69.             winText.text = "You Win!";
    70.     }
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Try checking the tags menu.

    There is a peculiar issue when creating tags and then exiting the project without saving properly or using undo after making the tags (I've not found the exact trigger) where the tags seem to be assigned (eg: the prefab and the instances say the "PickUp" as the tag) but when checking the tags and layers menu, the tag doesn't exist. As the prefabs seem to feel that they have been successfully tagged, they work in the editor. However, when the project is built, the tag doesn't actually exist, so it won't run.

    I've seen this reported a few times over the years this project has been around, but it's rare enough that I've never been able to track down the exact sequence of events that allows this to happen.

    SO:

    Check the pickups and make sure they are tagged.
    Check the tags and layers menu and see if the tag exists.
    If it doesn't exist, recreate the tag and then reassign that tag, if necessary, to the prefab and double check that it has propagated to the instances.

     
  6. jhirsh

    jhirsh

    Joined:
    Apr 16, 2017
    Posts:
    2
    Thank you, set me in the right direction. In my case each individual pickup and the prefab were properly tagged and the tag did exist. When i opened the tag/layers menu and re-saved and rebuilt it just seemed to resolve the issue.
     
  7. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yay!

     
  8. gforster67

    gforster67

    Joined:
    Apr 20, 2017
    Posts:
    10
    Good Afternoon, I am very new to Unity and to coding as well. I was following the tutorial for Roll-a-Ball and this is the code that I created for the movement script, but when I run this in Unity I get "All compilers errors have to fixed before you can enter playmode". When I downloaded Unity it is 5.6.0f3 and Visual Studio 2017.

    Any suggestions?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    9.    
    10.     void Start ()
    11.     {
    12.         rb = GetComponent<Rigidbody> ();
    13.     }
    14.  
    15.     void FixedUpdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.             Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.  
    22.         rb.AddForce (movement);
    23.     }
    24.  
     
  9. gforster67

    gforster67

    Joined:
    Apr 20, 2017
    Posts:
    10
    Ok I found out what was wrong, missing a bracket at the end of the code. It is working fine now.
     
  10. Skywire

    Skywire

    Joined:
    Apr 21, 2017
    Posts:
    2
    I'm doing the Roll a Ball tutorial (Step 2), and there's one problem:

    Whenever I preview the game, the ball will always floating be above the platform. If the plane is at y=0, the ball will be at y=1, essentially hovering above the platform.

    I double-checked my code, and finally just copy-and-pasted it into the script. However, no change in code has fixed this problem.

    Any suggestions?
     
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Glad you found the error!

    Yes, code can be fiddly and is cAsE SenSiTive... so watch your p's and q's and dot your i's and cross your t's and that will take care of 90% of the issues when you first get started.
     
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you post your code?? It shouldn't do that during play mode, as the ball should be under the influence of gravity.

    Did you set your ball up to be at (0, 0.5, 0)?
     
  13. knolli85

    knolli85

    Joined:
    Apr 3, 2017
    Posts:
    1
    Hello, I'm new and this is my first post in the forums. I have finished the tutorial without problems. Now I am playing around with Roll-A-Ball and trying to turn it into a "real game" and I am running into some difficulties.


    1. I am still using the same script and movement mechanics from the tutorial and I noticed that the player reacts weirdly to gravity when he, for some reason, looses contact with the ground. And I am not only talking about him still reacting to input, although that may be a part of the problem. After bumping in a dent in the ground (which shouldn't be there, see below), the player floats around for long seconds and far longer than a 1m diameter sphere (of any weight) should.
    Since I want to build some puzzles including ramps this is a problem.

    How do I check if the player is airborn? I want to change the script so that the player only reacts to commands when he is grounded. No more flying turns!
    How can I make the player fall faster and more realistically?



    2. I am using square tiles of 10 m per edge to build my labyrinth of a level. But although they are perfectly alligned according to the transform coordinates the player still stumbles over the edges (and consequently jumps around, sometimes even over the walls surounding the playing field, which brings us back to problem No. 1). Since I am a bloody beginner I simply ask: Why? Is it something I did wrong?
     
  14. Skywire

    Skywire

    Joined:
    Apr 21, 2017
    Posts:
    2
    Yes, the ball is at (0, 0.5, 0).
    Here is the code for the ball:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    9.  
    10.     void Start ()
    11.     {
    12.         rb = GetComponent<Rigidbody>();
    13.     }
    14.  
    15.     void FixedUpdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.  
    22.         rb.AddForce (movement * speed);
    23.     }
    24. }
     
  15. Deleted User

    Deleted User

    Guest

    Your code is okay. Did you add the rigidbody to the ball? Is "use gravity" ticked?
     
  16. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Does the collider look correct? Try resetting the sphere collider and see if that helps. I assume you've not scaled the ball or collider?
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Collider seams can be an issue, and usually it's best to do something procedural to add colliders that are not all chopped up, but that being said, I would not expect this to be an issue as you've described it.

    I may get the chance to run some tests to see if I can reproduce this.
     
  18. Mickee27

    Mickee27

    Joined:
    Apr 23, 2017
    Posts:
    5
    Hi There,

    I am brand new to using Unity and I am stuck on getting the winText to display correctly once I pick up all of the collectables. I think my code is right and that it is something that might be wrong with the position of the parent. With my current script both the count text and win text display on the game screen preview but the win text just doesn't display after I play and collect all the pick ups.

    I have the parent set to Screen Space - Overlay as that was the default, however it doesn't let me edit the x,y z values. X is set to 402 and Y is set to 172.5 also the width is 800 and height 343.2836. I can edit these values only when I change the parent to World Space but then both of my text disappear from the screen altogether.

    I have attached the script below just in case there is something there that I am missing.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4.  
    5. public class PlayerController : MonoBehaviour{
    6.  
    7.     public float speed;
    8.     public Text countText;
    9.     public Text winText;
    10.  
    11.     private Rigidbody rb;
    12.     private int count;
    13.  
    14.     void Start()
    15.     {
    16.         rb = GetComponent<Rigidbody>();
    17.         count = 0;
    18.         countText.text = "Count: " + count.ToString();
    19.         winText.text = "";
    20.     }
    21.  
    22.     void FixedUpdate()
    23.     {
    24.         float moveHorizontal = Input.GetAxis("Horizontal");
    25.         float moveVertical = Input.GetAxis("Vertical");
    26.  
    27.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical)
    28.  
    29.         ; rb.AddForce(movement * speed);
    30.  
    31.     }
    32.     void OnTriggerEnter(Collider other)
    33.     {
    34.         if (other.gameObject.CompareTag("pickup"))
    35.         {
    36.             other.gameObject.SetActive(false);
    37.             count = count + 1;
    38.             countText.text = "Count: " + count.ToString();
    39.         }
    40.     }
    41.  
    42.     void SetCountText()
    43.     {
    44.         countText.text = "Count: " + count.ToString();
    45.          if (count >= 12)
    46.         {
    47.                 winText.text = "You Win!";
    48.         }
    49.     }
    50. }
     
  19. Deleted User

    Deleted User

    Guest

    Your problem comes from the fact that you created the function "void SetCountText ()" but you never call it. In your script, replace all the lines that say:
    Code (CSharp):
    1. countText.text = "Count: " + count.ToString();
    by
    Code (CSharp):
    1. SetCountText ()
    except in the SetCountText () function itself, of course!

    Also, in your FixedUpdate () function:
    Code (CSharp):
    1.     void FixedUpdate()
    2.     {
    3.         float moveHorizontal = Input.GetAxis("Horizontal");
    4.         float moveVertical = Input.GetAxis("Vertical");
    5.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical)
    6.         ; rb.AddForce(movement * speed);
    7.     }
    the ";" before "rb.AddForce (movement * speed);" should be at the end of the previous line.

    About how to make the text component in itself, you should replay the video and remake it completely until it behaves like it should. ;)
     
    Mickee27 likes this.
  20. Mickee27

    Mickee27

    Joined:
    Apr 23, 2017
    Posts:
    5


    Thank you that helps a lot :)
     
  21. Faelnirv

    Faelnirv

    Joined:
    Apr 25, 2017
    Posts:
    1
    I am working on the Rolla Ball project in unity 5.6 and the code insn't working it says unexpected symbol 'float' and says what expects I changed the 'float' to what it wanted and it brought up 4 more errors pease help I will fail my class if I can't finish it.
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Have you restarted unity, your code editor and / or your computer?

    Did you load the script from within unity?

    Are you using the default code editor that came with unity?
     
  23. Ck36784

    Ck36784

    Joined:
    Apr 26, 2017
    Posts:
    2
    Hi,

    I was just wondering if this tutorial will cover the basics of C#, or do I need to learn that first before I begin this project?
     
  24. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You will be learning C# as you go. There is no point in the lesson where the lesson stops to teach C#, but C# is taught in context.
     
  25. phoenixian

    phoenixian

    Joined:
    Apr 27, 2017
    Posts:
    25
    Hello. Has this tutorial been extended with a multiplayer networking code example yet?
     
  26. Ck36784

    Ck36784

    Joined:
    Apr 26, 2017
    Posts:
    2
    Appreciate the help, thanks.
     
  27. Darkdragonkk

    Darkdragonkk

    Joined:
    Apr 22, 2017
    Posts:
    1
    Hello, Ive been following the tutorial step by step without any problems until I got to "Display the Score and text". Ive been rewriting the whole "playerController" over and over again and I still get an error when I go to run the game. I cannot get it to count the cubes I collect (Im a beginner). The console is saying that the problem is somewhere here:
    Code (CSharp):
    1.  void SetCountText ()
    2.     {
    3.         countText.text = "Count: " + count.ToString ();
    4.         if (count >= 12)
    5.         {
    This is what the error in the console looks like:


    Please help, thank you!

    ************EDIT****************

    I figured it out, somehow I didnt connect the CountText with countext in playerController. The tutorial is amazing, Im learning so much and its so fun! Thank you!
     
    Last edited: Apr 27, 2017
  28. geekomancer

    geekomancer

    Joined:
    Apr 23, 2017
    Posts:
    2
    Thank you Adam Buckner, for your fantastic tutorials! (Are you the voice in these?) Really great tutorials, spoken patiently, in clear English.

    My question: I was trying to set up a fun little math script to place the Pick Ups in a circle. It works, but I also get an 'Array index is out of range' error (for every Pick up object placed).

    I'm guessing this has to do with the fact that I'm calling transform.Rotate (in void Update()) outside of the array— so it's somehow calling the Pick Up objects twice — but I can't seem to figure out how to combine them. Here is my code, (in Rotator.cs):

    Code (CSharp):
    1.    
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class Rotator : MonoBehaviour
    7. {
    8.     float rand;
    9.  
    10.     [SerializeField]
    11.     private GameObject[] pickUps;
    12.  
    13.     // add variables to auto-place the Pick Ups
    14.     private float radius = 8f;
    15.     private float centerX = 0;
    16.     private float centerY = 0;
    17.     private float x, y;
    18.     private int pointsOnCircle = 12;
    19.     private float radians;
    20.     private float pi = Mathf.PI;
    21.  
    22.     void Start ()
    23.     {
    24.         PlaceThePickUps ();
    25.     }
    26.  
    27.     // Update is called once per frame
    28.     void Update ()
    29.     {
    30.         transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
    31.     }
    32.  
    33.     void PlaceThePickUps ()
    34.     {
    35.         for (int i = 0; i < pointsOnCircle; i++) {
    36.             radians = i * pi / (pointsOnCircle / 2);
    37.             x = radius * Mathf.Cos (radians) + centerX;
    38.             y = radius * Mathf.Sin (radians) + centerY;
    39.             pickUps [i].transform.position = new Vector3 (x, 1, y);
    40.         }
    41.     }
    42. }
    43.  
    Suggestions! Please, and thank you!
     
  29. AbsenceOfVoid

    AbsenceOfVoid

    Joined:
    May 1, 2017
    Posts:
    12
    Hi,

    First, thanks for the _excellent_ tutorial!

    I followed it all the way and all goes fine until I try to build for Windows standalone. I suddenly get all kinds of errors hinting I'm missing assembly references.. I even copied all the scripts as-is from the tutorial pages to see if I had some mistakes in code. But no, the same..

    What is especially interesting is that if I after these fail messages select WebGL and build again I get no errors and it's all fine, works as expected.. What's wrong? Some module installations missing?

    The type of messages I get are:

    - Assets/PlayerController.cs(5,33): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
    - Assets/Scripts/CameraController.cs(4,33): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
    - Assets/Scripts/Rotator.cs(4,24): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
    - Assets/PlayerController.cs(8,9): error CS0012: The type `UnityEngine.MonoBehaviour' is defined in an assembly that is not referenced. Consider adding a reference to assembly `UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

    And so on.. Any ideas what is this? I could imagine getting these errors if I missed "using" statements from files but as said they are now direct copies from tutorial pages. And any fundamental issues with scripting would probably be present with any build target. I finally even re-installed Unity (5.6.0f3) but cannot get rid of the error. I filed a bug report for this and after that noticed there's this official thread for this..
     

    Attached Files:

  30. Ramezov

    Ramezov

    Joined:
    May 2, 2017
    Posts:
    25
    This my first day using Unity, and I'm trying to complete this first tutorial but no matter what I do , I always get "All compiler errors has to be fixed before enter play mode" when I click play. I followed the tutorial step by step 3 times. I even opened the complete file provided with this tutorial, and I still getting the same message.
    Please help!
     
  31. AbsenceOfVoid

    AbsenceOfVoid

    Joined:
    May 1, 2017
    Posts:
    12
    Ramezov, I faced similar problems - after trying to build the project with the latest version of Unity. See my message above yours. I downloaded and installed the older version of the Unity and all works fine now ( version 5.5.3f1.)

    However, I think I had some general issues with the editor, and those actually had nothing to do with the tutorial in the end. Unity 5.6.0f3 was not able to build even almost empty project with single default script for Windows platform. All was ok for WebGL for instance.

    I noticed that this 5.5.3f1 version has Target Platform and Architecture dropdown menus in build window whereas 5.6.0f3 didn't have any of those. Maybe something wrong with the installation file? I even re-installed the 5.6.0f3 with the same unlucky results.
     
  32. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    Ramezov,

    You will need to post your scripts for analysis to determine what is going on. There are basically two types of errors you can get, compile time errors and run time errors. Compile time errors are typically easier to diagnose because it is telling you there is something wrong with you code and the compiler doesn't know what to do with it.

    If you are using visual studio to do your coding it should give some indication of what is wrong, usually a little red squiggly line. Also in your Unity console it should tell you where the issue is.
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    No, but you could try! Might be interesting to see what happens.
     
  34. Zedly

    Zedly

    Joined:
    May 3, 2017
    Posts:
    1
    I'm having issues getting my ball to move at all, and i'm wondering if it's because i'm writing my script in visual studios vs mono develop like the person shooting the tutorial.
     
  35. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Both monodevelop and visual studio are glorified text editors with lots of extra tools. You could, if you wanted to, write your script in note pad! So, it's either the script your written, or how you've used it in the scene.

    If it's your script, you can post the code here - and please use code tags.

    If it's how you've used it, you can post screen shots.

    It's probably best to show your code.
     
  36. Deleted User

    Deleted User

    Guest

    Hi Guys, great work here with those tutorials.
    I tried to add my contribution to your work by translating the first video (episode 0) to french on Amara but the sync doesn't seem's to work. (Captions send 4 days ago) Is there any way for you to check on that, or to manually add the french caption on YouTube if i provide you the .srt file?
    Waiting for the answer before translating all the other videos from the Roll-a-Ball tutorials.
    Thanks for your time and keep up. =)
     
  37. Deleted User

    Deleted User

    Guest

    That'll never work. You are trying to store the pickups in an array inside the pickup. Your rotator.cs is attached to the PickUp object, the array will never work like that.

    The way to do this is to create a new script. and make that script instantiate the pickups and set their position.

    -Reset the rotator.cs to the one used in the tutorial.
    -Create an empty object.
    -Rename it "PlacePickUp".
    -On that empty object, create a new script called "PlacePickUp"
    edit the script to
    Code (csharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlacePickUp : MonoBehaviour {
    6.  
    7.  
    8.  
    9.  
    10. public GameObject pickUps;
    11. public int pointsOnCircle;
    12.  
    13. private float radius = 8f;
    14. private float centerX = 0;
    15. private float centerY = 0;
    16. private float x, y;
    17.  
    18. private float radians;
    19. private float pi = Mathf.PI;
    20.  
    21. void Start()
    22. {
    23.  
    24. for (int i = 0; i < pointsOnCircle; i++)
    25. {
    26. radians = i * pi / pointsOnCircle ;
    27. x = radius * Mathf.Cos(radians*2) + centerX;
    28. y = radius * Mathf.Sin(radians*2) + centerY;
    29. Vector3 pickUpPosition = new Vector3(x, 1, y);
    30.  
    31. Instantiate(pickUps, pickUpPosition, Quaternion.identity);
    32.  
    33. }
    34. }
    35.  
    36. }
    37.  
    38.  
    link your pickup prefab to the public variable and voila.

    Bonus: I even set the "points on circle" to public so you can set the amount of pickup you want from unity without editing the script.
     
  38. Sledgehammer335

    Sledgehammer335

    Joined:
    Mar 17, 2017
    Posts:
    2
    hey so im getting argument exception input axis is not set up any idea whats that about
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Sadly, I'm not responsible for the Amara initiative, nor have I used it. I'm trying to find out who is responsible for that and I'll try to get back to you.

    If you can find out anything about how the tech works and how to fix the sync, that would be great.
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You probably have not spelled the name of the input exactly correctly.

    They need to be "Horizontal" and "Vertical". Spelling and capitalization counts.
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, definitely true. Remember that "Rotator" is on every pick up object, so every cube will try to execute that code, which is not desirable. You need a controller like Gutthegut suggest that does the action of placing the scripts.

    Think of this in the big picture: You have a dozen workers who are supposed to be digging a hole. You need a supervisor telling them where to dig. Each worker is not going to be telling all of the other workers what to do while they are doing their work.

    There is another layer to think about, as well, though this is intermediate in nature.

    Do you really need this script in your game and in your level?

    - or -

    Do you simply need a utility during EDIT TIME that places your GameObjects?

    What you may want to look into is Editor Scripting, which allows you to create new editor tools, like writing a "place pickup" script.

    What is important to know about this is that you can write scripts in C# that only run in the editor and don't need to be taking up space and resources as part of your game.

    This is intermediate, and you may not want to get into it now, but there are a number of lessons on the learn site that can help with this:

    https://unity3d.com/learn/tutorials/topics/scripting/creating-basic-editor-tools
    https://unity3d.com/learn/tutorials/topics/scripting/editor-scripting-intro
    https://unity3d.com/learn/tutorials/topics/interface-essentials/property-drawers-custom-inspectors
    https://unity3d.com/learn/tutorials/topics/tips/unity-tips-tricks-3 (One segment in this makes an editor script)
    https://docs.unity3d.com/Manual/ExtendingTheEditor.html
     
  42. Deleted User

    Deleted User

    Guest

    Seem's like you need to send a support request to Amara to fix the broken sync. (Some other caption (russian one) don't sync to youtube too)

    Hope you'll not have to do this for each vids, it could be really anoying to send a ticket for each one of them. :/
    I'll caption the episode 1 this night to see if it's only episode 0 who's bugging.
     
  43. CwebXIV

    CwebXIV

    Joined:
    Jun 18, 2015
    Posts:
    9
    Still fairly new to Unity and C# I keep getting the "All compilers errors have to fixed before you can enter playmode". Popup and, in the console it says:

    Assets/Scripts/PlayerMovement.cs(17,8): error CS1525: Unexpected symbol `float'
    Assets/Scripts/PlayerMovement.cs(19,58): error CS1525: Unexpected symbol `0
    Assets/Scripts/PlayerMovement.cs(19,73): error CS1525: Unexpected symbol `)'

    anyone know what I'm doing wrong? I re wrote the code maybe twice and checked for any errors
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    9.  
    10.     void Start ()
    11.     {
    12.         rb = GetComponent<Rigidbody> ();
    13.     }
    14.  
    15.     void FixedUpdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.  
    22.         rb.AddForce (movement);
    23.     }
    24. }
     
  44. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Is there any chance at all that you could have made changes and forgotten to save?

    If you go into the console and double click on the error, does it take you to this script?
     
  45. Blockinlick

    Blockinlick

    Joined:
    May 9, 2017
    Posts:
    4
    Very basic issue here. It may just be an outdated Unity version the guide is using or something though. I'm using 5.60f3 but I noticed the guy in the video has a slightly different layout, which made things slightly more tedious than otherwise. Even worse, I've hit a snag with the part where he says to select "Input" in the code and hit Ctrl + '. The Ctrl +' hotkey doesn't do anything. I try to click the window on the right where it says "Search Work Items (Ctrl + ')" but it doesn't open up for text input.
     
  46. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Be aware that you can change your layout by dragging the windows within the editor. This is shown at the following video at about 4:20:
    https://unity3d.com/learn/tutorials/topics/interface-essentials/interface-overview

    Are you using Monodevelop for your script editor? The "command/control + ' "should be working out of the box in Monodevelop. If you are using another scripting editor, you may need to set this up yourself.

    What script editor are you using.
     
  47. Blockinlick

    Blockinlick

    Joined:
    May 9, 2017
    Posts:
    4
    Dumb response perhaps, but I'm using whatever came default with Unity. When I clicked to edit the script, a program called Visual Studio automatically came up with the script to edit. I'm assuming/hoping that's what you're referring to.

    EDIT: EDIT: Didn't realize Unity had multiple options as default for script editors. I figured out how to switch to MonoDevelop and that worked. Basically, I shouldn't waste my time with Visual Studio lol
     
    Last edited: May 10, 2017
  48. Deleted User

    Deleted User

    Guest

    Yeah, Visual Studio is selected by default in the installer; it shouldn't, since you don't need it. Last time I installed it, it installed a whole pile of bloatware and ended up taking 37 gB on my drive... :eek: I won't get caught twice. ;)
     
  49. Blockinlick

    Blockinlick

    Joined:
    May 9, 2017
    Posts:
    4
    Okay. Now I am getting this error saying

    "No MonoBehaviour scripts in the file, or their names do not match the file name".
     
  50. Deleted User

    Deleted User

    Guest

    The name of the script must be the same as the name you gave to the class. Example with a small destroy script; the name of the script is Destroy.cs and the name of the class is Destroy:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Destroy : MonoBehaviour      //name of the class
    6. {
    7.     public GameObject other;
    8.  
    9.     void Update ()
    10.     {
    11.         if (Input.GetButtonDown("Delete"))
    12.         {
    13.             Destroy(other, 3f);
    14.         }
    15.  
    16.         //destroy component
    17.         if (Input.GetButtonDown("Tab"))
    18.         {
    19.             Destroy(other.GetComponent<MeshRenderer> ());
    20.         }
    21.     }
    22. }