Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

How to apply a knockback without it looking like teleportation?

$
0
0
So I have the following script which applies force when a player gets hit. I like the speed that the knockback is currently set to, but I would like for the player to move back more smoothly instead of him instantly moving back. Here is the script: public class meleeAttack : MonoBehaviour { int speed = 1000; void Start() { } void Update() { } void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Player" && Input.GetKeyUp(KeyCode.F)) { other.GetComponent().AddForce(transform.forward * speed); } } } What would be the best approach to achieving this?

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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