Question by
camccar23 · Feb 17, 2021 at 04:22 PM ·
beginnerroll a ball
,Roll-A-Ball ball isn't moving
I am using Unity 2019.4.17f1. I copied what she did in the tutorial but the ball doesn't move when I enter play mode. Am I missing something?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 0;
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); //f = this is a float value
rb.AddForce(movement * speed);
}
}
Comment