Double Jump in Fighting Game,Double Jump with Force
I am having difficulty with Jumping in my fighting game (like Super Smash Bros).
I was using a jumping script based on the Rigidibody2D.velocity but the problem with it was that when an opponent hits the player (Force gets applied to the player) he could just deny the knockback with pressing the jump button.
Thats why I wanted to change the jump to a force jump but double jumping doesn't quite work how I want it to be, and another problem for me is how to implement shorthops and long hops in it. It would be AWESOME if one of you guys could "translate" my velocity based script to a force based one.
My velocity jump
if (Input.GetKeyDown(jump) && jumped < 2) {
isGrounded = false;
rb.velocity = Vector2.up * jumpvelocity;
jumped++;
}
if (rb.velocity.y < 0) {
rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
} else if (rb.velocity.y > 0 && !Input.GetKey(jump)) {
rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
}
,I am having difficulty with Jumping in my fighting game. I was using a jumping script based on the Rigidibody2D.velocity but the problem with it was that when an opponent hits the player (Force gets applied to the player) he could just deny the knockback with pressing the jump button. Thats why I wanted to change the jump to a force jump but double jumping doesn't quite work how I want it to be, and another problem for me is how to implement shorthops and long hops in it. It would be AWESOME if one of you guys could "translate" my velocity based script to a force based one.
My velocity jump
if (Input.GetKeyDown(jump) && jumped < 2) {
isGrounded = false;
rb.velocity = Vector2.up * jumpvelocity;
jumped++;
}
if (rb.velocity.y < 0) {
rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
} else if (rb.velocity.y > 0 && !Input.GetKey(jump)) {
rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
}
Answer by PersianKiller · Jan 21, 2018 at 11:51 AM
I think using a Rigidbody2D is a better idea,it's nice and simple,you could easily create a variable name knockback .so when it was false you can jump!!! If you didnot get the idea it watch these nice and simple tutorials
they will give you the idea how to do what you want.
part1(creating a character and animation stuff)
part2(add enemy)
part3(knock back)
Your answer
Follow this Question
Related Questions
How can i combine Coyote Time and Jump Buffering with double jump? 0 Answers
double jumping after falling off edge problem 1 Answer
[2D] Velocity increases faster after large force is applied. 0 Answers
Problem with force movement when calling from another scripts 0 Answers
There is a way to set a max to the resultant force in a object ? 1 Answer