简体   繁体   中英

Unity C# - Rigidbody.AddForce not working as intended

So, I am trying to make a cube move with the WSAD buttons and for some reason, even though I am not touching any buttons, it moves diagonally up and to the left. I am using Unity 4.5.1

Code:

using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour {
    public float moveSpeed;
    private Vector3 input;

    // Use this for initialization
    void Start () {
    }

    // Update is called once per frame
    void Update () {
        input = new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
        print(input); 
    }
}

Your problem may be somewhere else, because the code seems just fine. If I were you, I'd try to take a look to this page . You might find the solution to this issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM