I went through all of the instructions exactly up to this point (step 9):
Roll-a-ball step 9 video tutorial
I can’t get the ball to move, nor the C# variable speed
to appear as a parameter in Unity editor (2 issues).
I tried setting the speed to 10.0f manually in the code, and the ball still won’t move. There are no compilation or runtime errors.
My script is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class NewBehaviourScript1 : MonoBehaviour
{
private float speed = 10.0f;
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 * speed);
}
}