Question by
tkohlfortes2008 · Sep 19, 2017 at 12:02 AM ·
jumpplayer movement
How to stop player (Roll a ball game) from infinite jumping?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControleDaBola : MonoBehaviour {
public float velocidade = 5;
public float forcaPulo = 100;
Rigidbody fisica;
// Use this for initialization
void Start () {
fisica = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
float movimentoX = Input.GetAxis ("Horizontal");
float movimentoY = Input.GetAxis ("Vertical");
fisica.AddForce (movimentoX * velocidade, 0 , movimentoY * velocidade);
if (Input.GetKeyDown (KeyCode.Space) || Input.GetKeyDown (KeyCode.LeftShift)) {
fisica.AddForce (0, forcaPulo, 0);
}
}
}
How to fix it?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612135139im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Jumping Function in my Player Controller Script isn't working 2 Answers
Player making "random jumps" while is moving at random places (Unity 2D) 0 Answers
How to add a jump key 2 Answers
how to jump in parabola. 0 Answers
How to make a jump directional 1 Answer