- Home /
**C#: I can't solve this problem! please help!**,**C#: How it must work?(it isn't working)**
Player isn't moving, and I can't solve this problem:
,Player isn't moving, and I can't solve this problem:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == touchPhase) { touchPosWorld = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); Vector2 touchPosWorld2D = new Vector2(touchPosWorld.x, touchPosWorld.y);
RaycastHit2D hitInformation = Physics2D.Raycast(touchPosWorld2D, Camera.main.transform.forward);
if (hitInformation.collider != null)
{
GameObject touchedObject = hitInformation.transform.gameObject;
if (touchedObject == upButton.transform.gameObject)
{
if (!(isJumping))
{
rb.AddForce(Vector2.up * jumpHeight);
isJumping = true;
}
void OnCollisionEnter(Collision2D col)
{
if(col.gameObject.tag == "ground")
{
isJumping = false;
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Clamps won't work! 1 Answer
How to change the quality of the game while playing it? 1 Answer
Unity 3D 2018.1 - Save 0 Answers
Moving from Java to Unity 4 Answers
Multiple Cars not working 1 Answer