Jump by touch Unity C#
I writing game on Unity C#
This is simple runner.
I have Platformer2DUserControl Script.
Here is it
using UnityEngine;
using UnitySampleAssets.CrossPlatformInput;
namespace UnitySampleAssets._2D
{
[RequireComponent(typeof (PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehaviour
{
private PlatformerCharacter2D character;
private bool jump ;
private void Awake()
{
character = GetComponent<PlatformerCharacter2D>();
}
private void Update()
{
if (Input.touchCount > 0)
character.Move(1, false, jump);
if (!jump)
// Read the jump input in Update so button presses aren't missed.
jump = CrossPlatformInputManager.GetButtonDown("Jump");
}
private void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.GetKey(KeyCode.LeftControl);
// float h = CrossPlatformInputManager.GetAxis("Horizontal");
// Pass all parameters to the character control script.
character.Move(1, false, jump);
jump = false;
}
}
}
I try to make that player jumps when i touch screen on my phone.
But it don't jump.
What wrong in my code?
Thank's for help.
Comment
Your answer
Follow this Question
Related Questions
Two finger tap causes jump bug 0 Answers
Multitouch doesn't work 1 Answer
Why is my multi touch not working? 1 Answer
buttons vs touch. 1 Answer