- Home /
Question by
Lucasqdrs · Sep 03, 2019 at 04:22 AM ·
movementtouch2d-gameplay
Hello, I'm having a problem with the character's touch, when playing to jump it is falling and leaving the scene, What should I do?
void Update()
{
if (Input.touchCount > 0)
{
toque = Input.GetTouch(0);
if (toque.phase == TouchPhase.Began)
{
if (toque.position.x > (Screen.width/2))
{
if (isGrounded == true)
{
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, tampulo));
GetComponent<Animator>().SetBool("jumping", true);
}
else
{
GetComponent<Animator>().SetBool("jumping", false);
}
}
else if (toque.position.x < (Screen.width/2))
{
if (isGrounded == true)
{
GetComponent<Animator>().SetBool("atack", true);
}
else
{
GetComponent<Animator>().SetBool("atack", false);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Touch movement not working 1 Answer
Drag to move movement like the iPhone messenger game EverWing 1 Answer
store the user touch input 0 Answers
How to drag object along with dragging touch? 1 Answer
Help with iphone/android touch controls 2 Answers