Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to make arch knockback

$
0
0
So I want my character to be knocked back when it's hit by an enemy. I tried to use this tutorial, https://www.youtube.com/watch?v=sdGeGQPPW7E. But it did not have the desired affect I was looking for. This is the curve I am getting when the player gets knocked back with the code below. (don't mind the height) ![alt text][1] and this is what I would like. ![alt text][2] This is the code I currently have for the first curve. if(knockbackCount <= 0) { rb.velocity = new Vector2(input * speed, rb.velocity.y); } else { if(knockFromRight && isGrounded == true) { rb.velocity = new Vector2(-knockback, nothing); } else if(!knockFromRight && isGrounded == true) { rb.velocity = new Vector2(knockback, nothing); } else if(knockFromRight) { rb.velocity = new Vector2(-knockback, knockback); } else if(!knockFromRight) { rb.velocity = new Vector2(knockback, knockback); } knockbackCount -= Time.deltaTime; } Any help is welcomed, :) thank you! [1]: /storage/temp/169573-not-right-curve.png [2]: /storage/temp/169574-desired-curve.png

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>