Hello, I’m still new and looking to make a really simple script, but I’m having some problems with it. What I’m trying to do is to make jump + movement works like Mario or any other plataformer2d game.
Here’s the player movement script:
void Update () {
if(Input.touchCount>1){
Touch touch=Input.GetTouch (0);
if(Input.GetTouch(0).phase==TouchPhase.Stationary){
if(touch.position.x<Screen.width/2)
transform.Translate (-Vector2.rightspeedpTime.deltaTime);
if(touch.position.x>Screen.width/2)
transform.Translate (Vector2.rightspeedpTime.deltaTime);
}
if(Input.GetTouch(0).phase==TouchPhase.Ended){
transform.Translate (-Vector2.zero);
}
}
}
And then I created a button for the jump function, and when pointdown, the player should jump, but if I’m touching anywhere else on the screen (if touch.position.x<Screen.width/2 it should jump+move left), but I cannot make it accept more then one touch.
I’ve tried changing Input.touchCount for 2 or something like that but none worked, also I dont know if it would work with Touch[ ]
Tried this on jumpbutton script:
public void Jumpbutton(){
Touch touch=Input.GetTouch (0);
if(Input.touchCount==2)
player.rigidbody.velocity=Vector2.up * jumpsp;
if (Input.touchCount > 1 && touch.position.x < Screen.width / 2) {
player.rigidbody.velocity = Vector2.up * jumpsp;
transform.Translate (-Vector2.right * speedp * Time.deltaTime);
}
if (Input.touchCount > 1 && touch.position.x > Screen.width / 2) {
transform.Translate (Vector2.right * speedp * Time.deltaTime);
player.rigidbody.velocity = Vector2.up * jumpsp;
}
}
But no multitouch working…
Hope you guys understand, lots of thanks in advance