How to apply a knockback without it looking like teleportation?
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<Rigidbody>().AddForce(transform.forward * speed);
}
}
}
What would be the best approach to achieving this?
Comment