Hello!
I’ve been trying to make a 2d platformer. I’ve been following this tutorial
Which is very good because I like the way it handles collisions. I want to add an 8 way dash like in Marvel vs Capcom so you can move in different angles in the air.
I used this to get the dash
Which works fine for dashing straight ahead but when i try to get to dash in a 45 or 90 degree angle it does some weird stuff. I’m thinking its because I’m rotating my box collider which screws up the ray casting collisions or something.
Well is there any way I could move in a specific angle with out rotating my collider?
Here is my Dash coroutine
IEnumerator Boost(float boostDur, Vector2 boostVelocity, Quaternion boostAngle) //Coroutine with a single input of a float called boostDur, which we can feed a number when calling
{
isBoosting = true;
float time =0; //create float to store the time this coroutine is operating
canBoost = false; //set canBoost to false so that we can't keep boosting while boosting
while(boostDur > time) //we call this loop every frame while our custom boostDuration is a higher value than the "time" variable in this coroutine
{
time += Time.deltaTime; //Increase our "time" variable by the amount of time that it has been since the last update
transform.rotation = boostAngle;
//transform.rotation = Quaternion.Euler( 0, 0, 45 );
GetComponent<Rigidbody2D>().velocity = boostVelocity*1.2f; //set our rigidbody velocity to a custom velocity every frame, so that we get a steady boost direction like in Megaman
yield return 0; //go to next frame
}
isBoosting = false;
anim.SetBool ("Boosting", false);
yield return new WaitForSeconds(boostCooldown); //Cooldown time for being able to boost again, if you'd like.
canBoost = true; //set back to true so that we can boost again.
}