- Home /
Having problems with inputs.
I am having problems make my care move i have setup the inputs in project settings and have done it in code and i do not know why it is not working,
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Car : MonoBehaviour { private Rigidbody carRigid; public int speed; public int rotatespeed;
// Use this for initialization
void Start () {
carRigid = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
}
void FixedUpdate (){
if (Input.GetButton ("Drive")) {
carRigid.AddForce (transform.forward * speed * Time.deltaTime);
}
if (Input.GetButton ("Reverse")) {
carRigid.AddForce (transform.forward * -speed * Time.deltaTime);
}
if (Input.GetButton ("Left")) {
transform.Rotate (0, -rotatespeed, 0);
}
if (Input.GetButton ("Right")) {
transform.Rotate (0, rotatespeed, 0);
}
}
}
Answer by unidad2pete · Aug 19, 2017 at 01:40 AM
All code works fine for me, but maybe your speed float is to low. I needed set speed to 1000 to get an aceptable velocity, if speed is lower than 500, the force is not enought and you cant see diference,
Your answer
Follow this Question
Related Questions
Problems with Input.acceleration in Unity 4.1 1 Answer
error CS0117: `Input' does not contain a definition for `GetKeyDown' 1 Answer
Script error? BCE0077 0 Answers
touch input error - finger position offset 2 Answers
WebGL and I/O 1 Answer