Question by
qinyuanliu · Oct 01, 2021 at 10:08 AM ·
rigidbodyinputaddforcegetkey
Why when I press "RightArrow"the object do not go right?(only go forward),Why when I press "RightArrow" when the program start, the RES BOX does not move to right?
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class playerMovment : MonoBehaviour { public Rigidbody rb;
public float ForwardForce = 2000f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
//Fixed use when we use force or gravity something like that
void FixedUpdate()
{
//To speed up
rb.AddForce(0, 0, ForwardForce * Time.deltaTime);
if (Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(500 * Time.deltaTime, 0, 0);
// Debug.Log("right");
}
}
}
Comment
It still cannot work. But the strange problem is that the same code works on my other Windows laptop, but not on my mac laptop. Could it be a problem with the Apple laptop keyboard?