Search Unity

Rollaball tutorial is broken, my ball wont move!

Discussion in 'Community Learning & Teaching' started by wbreslin951, Aug 4, 2020.

  1. wbreslin951

    wbreslin951

    Joined:
    Oct 13, 2019
    Posts:
    1
    Been through about 10 different pages with 10 different solutions and none of them have been the issue im experiencing. I'm following the tutorial exactly as described and the ball doesn't move.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.InputSystem;
    public class PlayerController : MonoBehaviour
    {
    private Rigidbody rb;
    private float movementX;
    private float movementY;
    // Start is called before the first frame update
    void Start()
    {
    rb = GetComponent<Rigidbody>();
    }
    void OnMove(InputValue movementValue)
    {
    Vector2 movementVector = movementValue.Get<Vector2>();

    movementX = movementVector.x;
    movementY = movementVector.y;
    }
    void FixedUpdate()
    {
    Vector3 movement = new Vector3(movementX, 0.0f, movementY);

    rb.AddForce(movement);
    }
    }
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
  3. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Hello, my ball doesn't move as well. I had worked out it had something to do with the player input component. The thing is my player input component doesn't have any schemes to select from and the there is a second box ( see screen shot with behaviours listed? ) that looks differs to the screenshot above and to the tutorial.

    I am using unity version 2019.4.9f1 personal My code is below the screen shot.

    Any ideas on what i am doing wrong? Thanks in advance for any assistance.

    player input.png

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. public class PlayerController : MonoBehaviour
    7.  
    8. {
    9.     private Rigidbody rb;
    10.     private float movementX;
    11.     private float movementY;
    12.  
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.  
    18.         rb = GetComponent<Rigidbody>();
    19.  
    20.     }
    21.  
    22.     void OnMove(InputValue movementValue)
    23.     {
    24.         Vector2 movementVector = movementValue.Get<Vector2>();
    25.  
    26.         movementX = movementVector.x;
    27.         movementX = movementVector.y;
    28.     }
    29.  
    30.     void FixedUpdate()
    31.     {
    32.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    33.  
    34.         rb.AddForce(movement);
    35.     }
    36.  
    37. }
     
    SodaGummy likes this.
  4. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    Did you create the InputActions as shown in the tutorial (see Screenshot 1), or did you create them using the Asset Menu or by right-clicking in Project Window > Create > Input Actions (see Screenshot 2)?

    Screenshot 1
    upload_2020-9-9_0-22-4.png

    Screenshot 2
    upload_2020-9-9_0-23-38.png
     
    Corebolt, avilleret and steambucky like this.
  5. steambucky

    steambucky

    Joined:
    Sep 15, 2013
    Posts:
    33
    Thank you SO much. This is where i went wrong! Cheers!!!
     
  6. raziel183

    raziel183

    Joined:
    Oct 19, 2020
    Posts:
    2
    I have the same problem, except when I do it the right way (as screenshot 1) my inputs settings are blank. When I then select input actions, it is missing critical behaviours (such as "OnMove") vector 3.png vector 4.PNG
     
  7. raziel183

    raziel183

    Joined:
    Oct 19, 2020
    Posts:
    2
    It seems I had to reimport the inputactions are creating it :/
     
    Deleted User likes this.
  8. abed696

    abed696

    Joined:
    Nov 12, 2020
    Posts:
    1
    i added the action still ball doesn't move why :(
     
  9. idopongo

    idopongo

    Joined:
    Dec 23, 2021
    Posts:
    1
    What did you do wrong than? which of the options are incorrect?
     
  10. Lawjo

    Lawjo

    Joined:
    Nov 11, 2022
    Posts:
    1
    Last edited: Jan 6, 2023
  11. bottombend

    bottombend

    Joined:
    Nov 26, 2022
    Posts:
    1
    I'm having the same issue. I'm not sure I'll be able to solve this problem. I created the InputActions, but they do not work.