why do two of my codes when collided don't function properly?
so i was just testing around with a bunch of stuff and i made a sphere move, after that i wanted to make it jump the problem being that two of my codes didn't work together properly and i don't know what to do, here are the codes:
public class Jumping : MonoBehaviour
{
public float JumpForce;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * JumpForce, ForceMode.Impulse);
}
}
}
public class Controller2 : MonoBehaviour {
public float speed;
private Rigidbody rb;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
float H = Input.GetAxis ("Horizontal");
float V = Input.GetAxis ("Vertical");
rb.velocity = new Vector3 (speed * H, 0, speed * V);
}
}
these two code make the sphere simply go up by an inch and fall down at extremely slow speeds, but alone they function just fine thanks in advance
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612155050im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why is my Jump Height affected by Walls? 2 Answers
Issues Getting my GameObject to both Move Forward and Jump properly. 0 Answers
Jump landing jittering 0 Answers
Detect if velocity equals 0? 2 Answers
Player stuck when jumping into a wall 0 Answers