- Home /
Question by
RoyalScape · Nov 10, 2018 at 08:35 AM ·
androidvelocitydashconstant
Player Dashing forward not remaining same in all devices(android)
In Unity Editor Dashing is constant but in mobile device it gives different results.. sometime player dash too far and sometime dash normally. How can I get same results of dashing in unity editor and same in android devices. please help. Thank you.
void Update()
{
//dash
if (direction == 0)
{
if (!facingRightt && (CrossPlatformInputManager.GetButtonDown("Dash")) && isGrounded == true)
{
direction = 1;
}
else if (facingRightt && (CrossPlatformInputManager.GetButtonDown("Dash")) && isGrounded == true)
{
direction = 2;
}
}
}
void FixedUpdate()
{
if(direction == 1 || direction == 2)
{
if (dashTime <= 0)
{
direction = 0;
dashTime = startDashTime;
myRB.velocity = Vector2.zero;
}
else
{
dashTime -= Time.fixedDeltaTime;
if (direction == 1)
{
if (this.anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack") || this.anim.GetCurrentAnimatorStateInfo(0).IsTag("Dash"))
{
return;
}
else
{
AudioManager.instance.PlaySound("DashSound");
anim.SetTrigger("Dash");
myRB.velocity = Vector2.left * dashSpeed * Time.fixedDeltaTime;
}
}
else if (direction == 2)
{
if (this.anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack") || this.anim.GetCurrentAnimatorStateInfo(0).IsTag("Dash"))
{
return;
}
else
{
AudioManager.instance.PlaySound("DashSound");
anim.SetTrigger("Dash");
myRB.velocity = Vector2.right * dashSpeed * Time.fixedDeltaTime;
}
}
}
}
}
Comment