Question by
Lone-_-Wolf · Oct 04, 2016 at 08:39 PM ·
movementaddforce
I am very new to c# and all this. I am an absolute beginner and i am stuck at this very simple code. Please help me on how do i increase the speed of the object and how do i get it to jump on pressing spacebar?
public class PlayerController : MonoBehaviour {
private Rigidbody rb;
void Start () {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate () {
float movehorizontal = Input.GetAxis("Horizontal");
float movevertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(movehorizontal, 0, movevertical);
rb.AddForce(movement);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612094007im_/https://answers.unity.com/themes/thub/images/avi.jpg)