Delayed jump on android
Hey, I'm working on a mobile app 2D and I have a button with a script that supposed to make the player jump, and it works. The only thing there is, is that when I press it there is a short delay from when I press the button until the player jumps. It's really annoying so I hope you'll be able to help me. Thanks!
P.s: on my cumputer it's working just fine but not on my phone.
Here is the script im using:
 public void Jump()
 {
     if (Grounded) 
     {
         Jumping = true;
         Grounded = false;
         rb.AddForce (new Vector2 (rb.velocity.x, jumpSpeedY));
     }
 }
Answer by Cuttlas-U · Apr 09, 2017 at 05:03 PM
Hi;
 rigidbody2D.AddForce(Vector3.up * jumpSpeed * Time.deltaTime);
Try using "Time.deltaTime" in your script ;
if that doesn't work u can use "Time.fixedDeltaTime" too;
but i need tho whole code for this to awnser;
First of all, thanks u for answering. This isn't obvious. Here is the full script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Jump : $$anonymous$$onoBehaviour {
 public float jumpSpeedY;
 bool Grounded;
 Rigidbody2D rb;
 void Start () 
 {
     rb = GetComponent<Rigidbody2D>();
 }
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Ground") 
     {
         Grounded = true;
     }
 }
 public void $$anonymous$$obileJump()
 {
     if (Grounded) 
     {
         Grounded = false;
         rb.AddForce (new Vector2 (rb.velocity.x, jumpSpeedY));
     }
 }
}
I've changed it a little bit since as u can see, I don't need the "Jumping" bool as in the first script. Again, thanks you!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                