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

Making knockback smooth instant of instant

$
0
0
I am working on a simple melee attack mechanic but I noticed that no matter what speed I set the knockback to, it always seems like the character just instantly moves back instead of smoothly doing it. Is there a way to make it so I can keep the speed in which the knockback is applied but see the character "slide" back instead of teleporting back? Here is the code I'm using: 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); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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