Question by
reecethom2002 · Mar 29, 2021 at 09:15 PM ·
rigidbody3dballcharacter movementroll a ball
character not moving, though code seems to be right
so im trying to make a simple roller ball following a tutorial on youtube, my code seems to be the same as his, but my character just wont move. im unsure if this is due to my input settings but WASD and the arrow keys do nothing.
any suggestions?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallMovement : MonoBehaviour
{
public float ballSpeed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float xSpeed = Input.GetAxis("horizontal");
float ySpeed = Input.GetAxis("vertical");
Rigidbody rb = GetComponent<Rigidbody>();
rb.AddTorque(new Vector3(xSpeed,0,ySpeed) * ballSpeed * Time.deltaTime);
}
}
heres the youtube tutorial too: https://www.youtube.com/watch?v=yiv57JuzaHs
Comment