Question by
kaiserzx2204 · Feb 03, 2021 at 11:00 PM ·
roll a ball
My Roll-a-Ball is not working properly? The keys are all messed up,Roll-A-Ball not working properly? My ball somehow moves left when I pressed the up key and moves down when I pressed the left key
Hi there, I'm a very beginner of unity and doing my first tutorial, roller ball. I have a problem when I play it, the ball isn't moving in the right direction and my code is correct. My ball somehow moves left when I pressed the up key and moves down when I pressed the left key and the other keys are mixed up too, and I already checked the Input Manager and it's normal too. Below is my code:
//
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerController : MonoBehaviour { // public float speed;
// Update is called once per frame
void FixedUpdate()
{
float moveH = Input.GetAxis("Horizontal");
float moveV = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveH, 0.0f, moveV);
GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
}
}
Comment