Unity2d .velocity dash speed
Hey Guys!
I am trying to make my character dash like in the game Celeste when you press X. I tried with iTween and it worked by setting the Rigidbody to kinematic on keyDown and setting back to dynamic after 1 second (for example). However it didn't work with collisions as it just entered inside collisions or went trough them. I tried onCollisionEnter2D already but that didn't work exactly as expected (simply stop iTween on collision).
So i did it with rigidbody2d.velocity, it works but I would like it to happen faster. For example:
If i set the velocity to 10, it dashes fast but also far away, I would simply like it to move fast but not too far.
Any ideas how to achieve that? Here is my function:
void DashFunction(float dashSpeedX, float dashSpeedY, float Time)
{
myAnim.SetBool("doubleJump", !(isGrounded));
player.gravityScale = 0;
player.velocity = new Vector2(dashSpeedX, dashSpeedY);
canMove = false;
canDash = false;
Answer by tbngrd · Jul 29, 2018 at 11:49 AM
Hey, sorry for digging up the old thread. I‘m currently having the exact same problem an was wondering whether you found any solution? @MattChowski
Answer by ncp12 · Nov 28, 2021 at 06:56 AM
maybe...set your collision detection on your rigidbody to continuous? might help, worth a shot.
Your answer
Follow this Question
Related Questions
dash till puff game 0 Answers
Jump at fixed height on single touch : Unity 2D 0 Answers
slow down certain objects 1 Answer
Enemys velocity in 2D platformer 0 Answers
Unity Player bumps when falls and dash 0 Answers