Search Unity

Official Roll-a-ball Tutorial Q&A

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

  1. Cookieg82

    Cookieg82

    Joined:
    Mar 28, 2017
    Posts:
    73
    Download and install Visual Basic Community edition from Microsoft.
     
  2. Cookieg82

    Cookieg82

    Joined:
    Mar 28, 2017
    Posts:
    73
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class BallCamera : MonoBehaviour
    4. {
    5.  
    6.     private static readonly float PanSpeed = 20f;
    7.     private static readonly float ZoomSpeedTouch = 0.1f;
    8.     private static readonly float ZoomSpeedMouse = 0.5f;
    9.  
    10.     private static readonly float[] BoundsX = new float[] { -10f, 5f };
    11.     private static readonly float[] BoundsZ = new float[] { -18f, -4f };
    12.     private static readonly float[] ZoomBounds = new float[] { 10f, 85f };
    13.  
    14.     private Camera cam;
    15.  
    16.     private Vector3 lastPanPosition;
    17.     private int panFingerId; // Touch mode only
    18.  
    19.     private bool wasZoomingLastFrame; // Touch mode only
    20.     private Vector2[] lastZoomPositions; // Touch mode only
    21.  
    22.     void Awake()
    23.     {
    24.         cam = GetComponent<Camera>();
    25.     }
    26.  
    27.     void Update()
    28.     {
    29.         if (Input.touchSupported && Application.platform != RuntimePlatform.WebGLPlayer)
    30.         {
    31.             HandleTouch();
    32.         }
    33.         else
    34.         {
    35.             HandleMouse();
    36.         }
    37.     }
    38.  
    39.     void HandleTouch()
    40.     {
    41.         switch (Input.touchCount)
    42.         {
    43.  
    44.             case 1: // Panning
    45.                 wasZoomingLastFrame = false;
    46.  
    47.                 // If the touch began, capture its position and its finger ID.
    48.                 // Otherwise, if the finger ID of the touch doesn't match, skip it.
    49.                 Touch touch = Input.GetTouch(0);
    50.                 if (touch.phase == TouchPhase.Began)
    51.                 {
    52.                     lastPanPosition = touch.position;
    53.                     panFingerId = touch.fingerId;
    54.                 }
    55.                 else if (touch.fingerId == panFingerId && touch.phase == TouchPhase.Moved)
    56.                 {
    57.                     PanCamera(touch.position);
    58.                 }
    59.                 break;
    60.  
    61.             case 2: // Zooming
    62.                 Vector2[] newPositions = new Vector2[] { Input.GetTouch(0).position, Input.GetTouch(1).position };
    63.                 if (!wasZoomingLastFrame)
    64.                 {
    65.                     lastZoomPositions = newPositions;
    66.                     wasZoomingLastFrame = true;
    67.                 }
    68.                 else
    69.                 {
    70.                     // Zoom based on the distance between the new positions compared to the
    71.                     // distance between the previous positions.
    72.                     float newDistance = Vector2.Distance(newPositions[0], newPositions[1]);
    73.                     float oldDistance = Vector2.Distance(lastZoomPositions[0], lastZoomPositions[1]);
    74.                     float offset = newDistance - oldDistance;
    75.  
    76.                     ZoomCamera(offset, ZoomSpeedTouch);
    77.  
    78.                     lastZoomPositions = newPositions;
    79.                 }
    80.                 break;
    81.  
    82.             default:
    83.                 wasZoomingLastFrame = false;
    84.                 break;
    85.         }
    86.     }
    87.  
    88.     void HandleMouse()
    89.     {
    90.         // On mouse down, capture it's position.
    91.         // Otherwise, if the mouse is still down, pan the camera.
    92.         if (Input.GetMouseButtonDown(0))
    93.         {
    94.             lastPanPosition = Input.mousePosition;
    95.         }
    96.         else if (Input.GetMouseButton(0))
    97.         {
    98.             PanCamera(Input.mousePosition);
    99.         }
    100.  
    101.         // Check for scrolling to zoom the camera
    102.         float scroll = Input.GetAxis("Mouse ScrollWheel");
    103.         ZoomCamera(scroll, ZoomSpeedMouse);
    104.     }
    105.  
    106.     void PanCamera(Vector3 newPanPosition)
    107.     {
    108.         // Determine how much to move the camera
    109.         Vector3 offset = cam.ScreenToViewportPoint(lastPanPosition - newPanPosition);
    110.         Vector3 move = new Vector3(offset.x * PanSpeed, 0, offset.y * PanSpeed);
    111.  
    112.         // Perform the movement
    113.         transform.Translate(move, Space.World);
    114.  
    115.         // Ensure the camera remains within bounds.
    116.         Vector3 pos = transform.position;
    117.         pos.x = Mathf.Clamp(transform.position.x, BoundsX[0], BoundsX[1]);
    118.         pos.z = Mathf.Clamp(transform.position.z, BoundsZ[0], BoundsZ[1]);
    119.         transform.position = pos;
    120.  
    121.         // Cache the position
    122.         lastPanPosition = newPanPosition;
    123.     }
    124.  
    125.     void ZoomCamera(float offset, float speed)
    126.     {
    127.         if (offset == 0)
    128.         {
    129.             return;
    130.         }
    131.  
    132.         cam.fieldOfView = Mathf.Clamp(cam.fieldOfView - (offset * speed), ZoomBounds[0], ZoomBounds[1]);
    133.     }
    134. }
    The above code allows you to pinch the screen and zoom in/out on a touch screen device. Drag the script onto your main camera. If you mean how to just simply zoom out when in scene mode use the mouse wheel. (Quick zoom - no idea!?)
     
  3. Kruton3

    Kruton3

    Joined:
    Aug 22, 2017
    Posts:
    1
    Hi. I have some issues with the text. In the editor and while playing it through the editor everything looks fine, but when I build and run it all the texts on the screen changes into pink squares. Im using Windows 7 with pretty old GPU - Geforce 9800 GT, could that be the problem?
     
  4. colton200456

    colton200456

    Joined:
    Aug 22, 2017
    Posts:
    3
    Hello, I am having an issue. my game worked perfectly in Unity, then when I did the build for mac and ran it, it seems to not detect the collision of the squares. it hits off the wall and displays the text just fine, but I can't collect the boxes.

    any help would be appreciated.
    Colton
     
    adammy123 likes this.
  5. schulmkg

    schulmkg

    Joined:
    Aug 25, 2017
    Posts:
    7
    I have the same problem... it turns out the tutorial video makes ZERO mention of the need to write a script to make the ball roll. And that is extremely frustrating. I probably wasted a full hour trying to figure out what was going on
     
  6. Dordal08

    Dordal08

    Joined:
    Aug 28, 2017
    Posts:
    1
    Hello! I am on the roll ball project, the move the player part, I have all the code written but my ball won't move?! I am getting no errors and it seems to run ok exept that the ball won't move! I have never programmed with c# so I am kinda lost PLEASE HELP!

    Here is my code:

    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. }
    I have tried hitting the WASD keys and the up down left right keys. nothing.

    [code tags added - mod]
     
    Last edited by a moderator: Sep 11, 2017
  7. Monzza

    Monzza

    Joined:
    Aug 28, 2017
    Posts:
    2
    I have the same problem as Dordal08. The ball won't move even though everything is as in the code above. I also tried to add a simple print () command inside UpDate and FixedUpdate brackets, but the print won't appear in the console. Seems like for some reason UpDate and/or FixedUpDate functions don'r run?! The print does appear in the Start () though...

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class PlayerControl : MonoBehaviour {
    7.  
    8.     public float speed = 10;
    9.  
    10.     private Rigidbody rb;
    11.  
    12.  
    13.  
    14.     void Start ()
    15.     {
    16.         rb = GetComponent<Rigidbody>();
    17.         print ("heiStart");
    18.  
    19.     }
    20.  
    21.     void UpDate ()
    22.     {
    23.         print ("heiUpdate");
    24.         float horizontal = Input.GetAxis ("Horizontal");
    25.  
    26.      
    27.             if (horizontal < 0) {
    28.                 print ("Horizzontal movement: " + horizontal);
    29.             }
    30.  
    31.  
    32.  
    33.  
    34.     }
    35.  
    36.     void FixedUpDate ()
    37.     {
    38.  
    39.         print ("heiFixedUpdate");
    40.         float moveHorizontal = Input.GetAxis("Horizontal");
    41.         float moveVertical = Input.GetAxis ("Vertical");
    42.  
    43.         if (moveHorizontal != 0) {
    44.             print ("Horizzontal movement: " + moveHorizontal);
    45.         }
    46.  
    47.         Vector3 movement = new Vector3 (moveHorizontal * 5, 0.0f, moveVertical * 5);
    48.  
    49.         rb.AddForce (movement * speed);
    50.  
    51.  
    52.  
    53.  
    54.     }
    55.  
    56. }
    [code tags added - mod]
     
    Last edited by a moderator: Sep 11, 2017
  8. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Doral,
    First, make sure you have a value set for "speed" in you FixedUpdate () method

    Second, try to post your code in "code" blocks - this will make nicer looking code, easier to comment on, and supply line numbers that we can direct out suggestion to. The code blocks start with the word "code" between to square brackets, followed by all your code, then the word /code between 2 square bracketw
    Code (csharp):
    1.  
    2. void FixedUpdate ()
    3. {
    4. float moveHorizontal = Input.GetAxis ("Horizontal");
    5. float moveVertical = Input.GetAxis ("Vertical");
    6.  
    7. Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    8.  
    9. rb.AddForce (movement * speed);
    10. }
    11. }
    12.  
    third, make sure you have no errors (compile or execution) in the console log
    Fourth, add
    ; immediately above rb.AddForce (movement * speed);
    so you have
    Code (csharp):
    1.  
    2. ... ...
    3. Debug.Log("speed="+speed);
    4. rb.AddForce (movement * speed);
    5. }
    6. }
    7.  
    fourth if none of this helps, then make sure you remove the "Completed game" directory tree from you project (if it exists)
     
  9. panoskal

    panoskal

    Joined:
    Mar 31, 2017
    Posts:
    28
    @Monzza
    It's Update and FixedUpdate.
    Not UpDate and FixedUpDate.
     
  10. Monzza

    Monzza

    Joined:
    Aug 28, 2017
    Posts:
    2
    Thank you!
     
  11. Cookieg82

    Cookieg82

    Joined:
    Mar 28, 2017
    Posts:
    73
    This is a completed "Working" Playercontroller Roll a Ball script - Please ignore/delete any variables or methods which you do not need. Hope this helps! Enjoy.

    Note
    : This has accompanying scripts which are not listed here. But the basics are in here. Plus just switch out the tilt controls for whatever you require. Thanks.

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     public Timer minustime;
    7.     public Timer plustime;
    8.     public float moveSpeed = 50f;
    9.     public float drag = 0.5f;
    10.     public float terminalRotationSpeed = 25.0f;
    11.     public Vector3 MoveVector { set; get; }
    12.  
    13.     public VirtualJoystick joystick;
    14.  
    15.     private Rigidbody rb;
    16.  
    17.     void Start()
    18.     {
    19.      
    20.  
    21.         rb = gameObject.GetComponent<Rigidbody>();
    22.         rb.maxAngularVelocity = terminalRotationSpeed;
    23.         rb.drag = drag;
    24.  
    25.         GameObject trail = Instantiate(Manager.Instance.playerTrails[SaveManager.Instance.state.activeTrail]);
    26.     }
    27.  
    28.     public void Update()
    29.     {
    30.         MoveVector = PoolInput();
    31.  
    32.         Move();
    33.     }
    34.  
    35.     public void Move()
    36.     {
    37.         rb.AddForce((MoveVector * moveSpeed));
    38.     }
    39.  
    40.     public Vector3 PoolInput()
    41.     {
    42.  
    43.         Vector3 dir = Vector3.zero;
    44.  
    45.         dir.x = joystick.Horizontal();
    46.         dir.z = joystick.Vertical();
    47.  
    48.         if (dir.magnitude > 1)
    49.             dir.Normalize();
    50.  
    51.         return dir;
    52.     }
    53.  
    54.     void OnTriggerEnter(Collider other)
    55.     {
    56.         if (other.gameObject.tag == "MinusTime")
    57.         {
    58.             Destroy(other.gameObject);
    59.             minustime.levelTimer -= 10;
    60.         }
    61.         else
    62.         {
    63.             if (other.gameObject.tag == "PlusTime")
    64.             {
    65.                 Destroy(other.gameObject);
    66.                 plustime.levelTimer += 10;
    67.             }
    68.         }
    69.         {
    70.             if (other.gameObject.tag == "Boost")
    71.             {
    72.                 StartCoroutine(speedBoost());
    73.             }
    74.         }
    75.     }
    76.     public IEnumerator speedBoost()
    77.     {
    78.         moveSpeed = 250f;
    79.         rb.AddForce(rb.velocity.normalized * moveSpeed * Time.deltaTime, ForceMode.Impulse);
    80.         yield return new WaitForSeconds(4f);
    81.         StartCoroutine(Reset());
    82.     }
    83.  
    84.     public IEnumerator Reset()
    85.     {
    86.         yield return new WaitForSeconds(1);
    87.         moveSpeed = 50f;
    88.     }
    89. }
    90.  
    91.      
    92.  
     
  12. PankakeFrier

    PankakeFrier

    Joined:
    Aug 30, 2017
    Posts:
    1
    Hi there,
    I am having trouble with the cubes rotating, I followed all the code in the video and it says "No MonoBehaviour scripts in the file Or their names do not match the file name"
    Please Help
     
  13. kentg1

    kentg1

    Joined:
    Dec 22, 2014
    Posts:
    168
    Will not work for just a few of my students? Same code and rigidbody placed

    Any ideas?


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

    panoskal

    Joined:
    Mar 31, 2017
    Posts:
    28
    @PankakeFrier
    Is the script file named Rotator?
    @kentg1
    Did they give speed a value inside the editor?
     
  15. kentg1

    kentg1

    Joined:
    Dec 22, 2014
    Posts:
    168
    We make the speed a public variable and we set it in the game, It works in about 90% of my students computers but in about 3-4 per class it THE BALL WILL NOT MOVE even with everything the same? We are all using Unity 5.5

    Thanks
     
  16. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144

    Everything is not the same. Most work, some don't.

    1. Confirm there are no error messages in the console log.
    2. Confirm the method names are spelled correctly, including upper and lower case.
    void FixedUpdate () is not the same as void FixedUpDate ()
    3. *** Confirm they have not accidentally made references to scripts or components in the "_Completed" game directory
    4. Take one student who's game works and one who's doesn't work and compare the Unity settings in the inspector,
    gameObject by gameObject.
    5. Use DebugLog statements.
    For example:
    Code (csharp):
    1.  
    2.     void FixedUpdate ()
    3.     {
    4.        // confirm you are entering the method, and the value is set
    5.        Debug.Log("Debugging controller.FixedUpdate.  Upon entry,  speed="+speed);
    6.         float moveHorizontal = Input.GetAxis ("Horizontal");
    7.         float moveVertical = Input.GetAxis ("Vertical");
    8.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    9.         rb.AddForce (movement * speed);
    10.     }
    11.  
    Make sure the method is entered by viewing the console log. Make sure the values are what you expect.

    that's a start anyway. You are in a very lucky position in that you have examples of working games that you can compare to non working games.
    Good luck
     
  17. titoufred

    titoufred

    Joined:
    Sep 1, 2017
    Posts:
    5
    Nice ! Could you share some of your code ?
     
  18. titoufred

    titoufred

    Joined:
    Sep 1, 2017
    Posts:
    5
    I had a problem trying to move the pickups, they would not move in the xz plan even if I selected it. To solve that I had to set the rotation x, y and z to 0 in "PickUps" (not in any PickUp game object).
     
  19. mc3

    mc3

    Joined:
    Mar 27, 2016
    Posts:
    19
    I am reading through some of the thread. I wanted to keep working on the tutorial.

    First idea was to use the walls to return velocity of ball, like the wall of a pool table.

    How can I go about doing that?
     
    Last edited: Sep 7, 2017
  20. abdulkhadersab

    abdulkhadersab

    Joined:
    Sep 7, 2017
    Posts:
    4
    i got problem in video 2 , where u add script and move the ball using arrow keys but in my case error pops up saying invalid vertical axis
     
  21. mc3

    mc3

    Joined:
    Mar 27, 2016
    Posts:
    19
    Check your syntax. Post your script.
     
  22. aryankhandelwal15

    aryankhandelwal15

    Joined:
    Sep 9, 2017
    Posts:
    1
    If i want to make games using unity,there is need any prior programming language to start.

    Thank You.
     
  23. DreamBliss

    DreamBliss

    Joined:
    Jul 10, 2014
    Posts:
    7
    Tutorial fails when it comes to the UI. First of all the Canvas box is HUGE! The workaround for me was to position the text in the bottom left corner. I copied and used the script from the video and the same names for my two text objects in Canvas, Count Text and Win Text. But on pressing play no text of any sort is displayed. On collecting all the pickups, no win message.

    I am using the latest builds of Unity 2017 and VS Code as of a few days ago. My OS is Windows 7 64-bit.

    Your voice, or the voice used in the lesson, sounds very familiar. I can't place it, but it sounds exactly like some famous voice I have heard in my past somewhere. It will come to me.

    Thanks for making these excellent tutorials. Please try this project using the latest build of Unity, address the errors, and update the lesson. Thank you.
     
  24. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is the scene view camera. I was simply using the zoom wheel on my mouse. You can also use the scroll-wheel equivalent on a track pad, typically two finger on the track pad moving up or down.
     
  25. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Double check that your tags are correct.

    Open the tags and layers panel and make sure that they are properly defined and then check in the prefab to make sure that the tags are properly assigned.
     
  26. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you still having issues? If you are, can you state clearly what it is that is not working for you?
     
  27. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you still having issues? If you are, can you please give us more information? Perhaps some screen shots?
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Your light is not pointing down onto your game area. Try changing the rotation of the transform on the camera.
     
  29. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is strange behavior ... have you solved this? It sounds like your input device may not be working... but there could be other issues.
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You would not import default colliders. I'm unclear if Blender can even export colliders. You would need to assign a MeshCollider instead of a Box or Sphere collider; and then assign the models mesh to the mesh collider.

    Be aware that mesh colliders are less efficient when compared to a primitive collider, such as a cube or sphere.
     
  31. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Double check that your tags are correct.

    Open the tags and layers panel and make sure that they are properly defined and then check in the prefab to make sure that the tags are properly assigned.
     
  32. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    So, the code is:

    Code (csharp):
    1.  
    2.    void Update ()
    3.    {
    4.        transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
    5.    }
    Every frame, in UPdate(), the code is run.

    Now let's pretend the code was:

    Code (csharp):
    1.  
    2.    void Update ()
    3.    {
    4.        transform.Rotate (new Vector3 (1, 0, 0));
    5.    }
    transform.Rotate will rotate the cube by 1 along the x axis - every frame.

    Now, let's say that every frame takes 0.015 seconds to run... and we multiply the rotation by 0.015:

    Code (csharp):
    1.  
    2.    void Update ()
    3.    {
    4.        transform.Rotate (new Vector3 (1, 0, 0) * 0.015);
    5.    }
    ... the code will rotate the cube by 0.015 each frame.

    This means that the cube will rotate at a value of 1 per second.

    If we substitute that hard number of 0.015 with Time.deltaTime, or the duration of the frame:

    Code (csharp):
    1.  
    2.    void Update ()
    3.    {
    4.        transform.Rotate (new Vector3 (1, 0, 0) * Time.deltaTime);
    5.    }
    ...each frame the cube will be rotated 'as much as it needs to be rotated' each frame, summing up to rotating at a value of 1 per second.

    Does this make sense?
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The act of destroying a GameObject and cleaning up the memory takes time and resources, so it's more efficient to simply deactivate them rather than destroying them.

    For a better and more in-depth explanation search "Unity Object Pooling" and this should make more sense.
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Double check that your tags are correct.

    Open the tags and layers panel and make sure that they are properly defined and then check in the prefab to make sure that the tags are properly assigned.
     
  35. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is strange behaviour... Are you stil having trouble?
     
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This should not be a problem. Unity works cross-platform.
    I am unclear what the problem is here. Can you state exactly what is going wrong?
    This is not a question we can answer here. New questions about how to do something that is not part of the tutorial should be posted in the main forum in the appropriate section. I would try the "getting started" forum:
    https://forum.unity3d.com/forums/getting-started.82/
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The optimization comes from the fact that Unity calculates the static colliders once when the scene first starts and then caches the results. The object with rigidbodies are calculated every frame. If we didn't add a rigidbody to the rotating objects, Unity would detect a change in the static geometry and recalculate ALL of the static geometry every frame, rather then fetching the values from the cache.
     
  38. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If you are still having issues, can you please post your code (using code tags) and a screenshot of your player GameObject?
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Double check that your tags are correct.

    Open the tags and layers panel and make sure that they are properly defined and then check in the prefab to make sure that the tags are properly assigned.
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Make sure that "isKinematic" is selected on the rigidbody.
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Pink squares means that the material is missing or cannot be rendered.

    Can you describe in more detail what you've done and what your setup is?
     
  42. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Double check that your tags are correct.

    Open the tags and layers panel and make sure that they are properly defined and then check in the prefab to make sure that the tags are properly assigned.
     
  43. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Did you miss a step? Each script is clearly laid out. If you accidentally missed a lesson, I'd like to know how and why, so no one else does this. At what stage did you miss the "moving the player" video?
    https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/moving-player?playlist=17141
     
  44. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Have you added any value into the "speed" property in the inspector?
     
  45. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Make sure that the class name matches the file name.

    If you have a file name of "PlayerController.cs", the main class needs to be
    Code (csharp):
    1. public class PlayerController : MonoBehaviour
    Any of the following will cause an error:
    Code (csharp):
    1. public class pController : MonoBehaviour
    Code (csharp):
    1. public class playerController : MonoBehaviour
    Code (csharp):
    1. public class playercontroller : MonoBehaviour
    Code (csharp):
    1. public class Playercontroller : MonoBehaviour
    ... as they don't match.

    Don’t forget C# is CaSe SeNsItIvE!
     
  46. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'm guessing that the class name and file name do not match.

    Your class name is "controller".

    If you have a file name of "PlayerController.cs", the main class needs to be
    Code (csharp):
    1. public class PlayerController : MonoBehaviour
    Any of the following will cause an error:
    Code (csharp):
    1. public class controller : MonoBehaviour
    Code (csharp):
    1. public class pController : MonoBehaviour
    Code (csharp):
    1. public class playerController : MonoBehaviour
    Code (csharp):
    1. public class playercontroller : MonoBehaviour
    Code (csharp):
    1. public class Playercontroller : MonoBehaviour
    ... as they don't match.

    Don’t forget C# is CaSe SeNsItIvE!
     
  47. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I believe this should be covered in the tutorial?? I forget now. Make sure that the editor's scene view is set to "Global" coordinates rather than "Local" coordinates.
     
  48. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You probably have a typo in your script.

    Input.GetAxis("vertikal") will not work. "Vertical" must be spelled correctly (or "Horizontal") and this is CaSe SeNSiTive.
     
  49. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Two solutions off the top of my head. If these don't work, post in the main forum!
    - You would need to detect the collision with the edge and use physics to add force.
    - You could use a "bouncy" physic material.
     
    mc3 likes this.
  50. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Our tutorials are set up to teach you the coding you need to know as you go along.

    There are many lessons in the learn site (unity3d.com/learn) that will help you learn the coding you need as well.