- Home /
Question by
Raiio · Jul 24, 2018 at 08:35 PM ·
androidtouchjumptouch controls
Fixed Jump on android phone
Basically, I need to rewrite this code to use touch input instead of mouse button, but I'm struggling with it
void Update()
{
#if UNITY_EDITOR
if (Input.GetMouseButtonDown(0) && canJump && jumpCount < maxJumpCount)
{
jumpCount += 1;
rb.velocity = Vector3.up * jumpVelocity;
}
//jump controll
if (rb.velocity.y < 0)
{
rb.velocity += Vector3.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
}
else if (rb.velocity.y > 0 && !Input.GetMouseButton(0))
{
rb.velocity += Vector3.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
}
#endif
}
Comment
Your answer
Follow this Question
Related Questions
Mutli-touch in android? 1 Answer
EventSystem.current.IsPointerOverGameObject(t.fingerId) - Not working on Android builds - Unity 2 Answers
GameObject won't jump with touch 1 Answer
Cross Platform Input Controller Not Working on Mobile Device 2 Answers
How to add Jump control from touch on screen? ANDROID 1 Answer