- Home /
Question by
qin2500 · Jul 04, 2019 at 04:19 PM ·
physicsrigidbody2dphysics2dtranform
My transform.up goes backwards when i set my rigidbody 2d to dynamic but works fine when set to Kinetic.
Ok, so in my code, I want to have to player dash forward for a little bit after pressing a button. I originally set the rigidbody 2d of my player to Kinematic and everything worked fine. Now, i need it to be Dynamic, so i changed it to Dynamic but the transform.up sends my player backwards and i don't know why. I even tried typing -transform.up but even that didn't work.
Here is the part of the code where i used transform.up:
if(dashing)
{
if (dashCooldown <= 0)
{
dashing = false;
rb.velocity = Vector2.zero;
dashCooldown = tempDashCoolDown;
dashWeapon.SetActive(false);
}
else
{
dashCooldown -= Time.deltaTime;
rb.velocity = transform.up * dashSpeed;
dashWeapon.SetActive(true);
}
}
Comment