Question by
matthewjparker99 · Feb 08, 2016 at 11:22 AM ·
jumpjumpingjumping object
Jumping higher the more you hold space!
Hi, im making a fast paced jumping game and thought when I was asleep how I could make it better! (my game dosent need to move left right and forward and backward, just jump) I want someone kind to please help me make a script where when you tap space it makes you jump a small amount but when you hold it you jump higher.
Thanks
Matt
Comment
How about first applying basic force of jumping, then applying additional force for limited time if space is still pressed?
Answer by jhunglow · Jul 27, 2016 at 03:27 AM
public float jumpHeight;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if(Input.GetKeyDown(KeyCode.Space)
{
rb.AddForce(Vector3.up * jumpHeight);
}
}