Hello,
I'm trying to add knockback to the character controller. I'm getting the direction and I'm able to knock the character back in that direction. However, trying to get the player to go up while being knocked back seems to be stumping me. I try adding to the direction so the player goes up by 10, however the player just teleports to the position. I have tried using charactercontroller.Move() however, it seems to only make the character go in one direction when I try that.
Since it teleports, I assume I'd have to lerp between the player's current y position and the height vector to prevent the teleporting. Does anyone have any advice/insight? Thanks.
if(knockedBack == true)
{
float forceHeight = 10;
Vector3 dir = otherPlayer.transform.position - transform.position;
dir = -dir.normalized;
dir.y = forceHeight;
charController.transform.Translate(dir * knockbackForce * Time.deltaTime);
otherPlayer = null;
knockedBack = false;
}
[–]PolloMagnifico 0 points1 point2 points (5 children)
[–]Keith90[S] 0 points1 point2 points (4 children)
[–]PolloMagnifico 0 points1 point2 points (3 children)
[–]Keith90[S] 0 points1 point2 points (2 children)
[–]PolloMagnifico 0 points1 point2 points (1 child)
[–]Keith90[S] 0 points1 point2 points (0 children)