- Home /
UI Controls Issue
I've created some UI for controlling player for mobile....I use buttons and then on sprite I added left/right sprites...I used Standard Assets for controls(CrossPlateformInputManager) its because I tried for myself the same issue was there...which Is....After Falling from platform, when scenemanager loads the same scene...those left/right controls aren't working … I tried by setting them to top of canvas but it didn't worked well...
Here is Controlscript....
private void Movement() { float HDirection = CrossPlatformInputManager.GetAxis("Horizontal");
if(canClimb && Mathf.Abs(CrossPlatformInputManager.GetAxis("Vertical")) > .1f)
{
state = State.climb;
rb.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
transform.position = new Vector3(ladder.transform.position.x, rb.position.y);
rb.gravityScale = 0f;
}
if(HDirection< 0)
{
rb.velocity = new Vector2(-speed, rb.velocity.y);
transform.localScale = new Vector2(-1, 1);
//anim.SetBool("running", true);
}
else if(HDirection > 0)
{
rb.velocity = new Vector2(speed, rb.velocity.y);
transform.localScale = new Vector2(1, 1);
//anim.SetBool("running", true);
}
if(CrossPlatformInputManager.GetButtonDown("Jump") && coll.IsTouchingLayers(ground))
{
Jump();
//anim.SetBool("running", false);
}
}
public void Jump()
{
rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
state = State.jumping;
}
and Fall script
public void OnTriggerEnter2D(Collider2D collide) { if(collide.gameObject.tag == "Player") { PermanentUI.perm.Reset(); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } }
How can I solve this...??