#Struggling to understand SmoothDamp
1 messages · Page 1 of 1 (latest)
Might as well show the whole code if youre having problems
Yup, i fixed the prior issue so It compiles without error
NOW my character doesnt move at all, and turning isnt smoothed kekeke, I suspect Ive done something wrong aha
One sec
I think I have an idea what it might be, will update
Ill be frankly honest, not sure what in my code rotates the player model
Code too long to paste RIP
private void MovePlayer()
{
// calculate movement direction
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
moveDir = Vector3.SmoothDamp(moveDir, moveDirection, ref moveDirRef, smoothDuration);
// on slope
if (OnSlope() && !exitingSlope)
{
rb.AddForce(GetSlopeMoveDirection() * moveSpeed * 20f, ForceMode.Force);
if (rb.velocity.y > 0)
rb.AddForce(Vector3.down * 80f, ForceMode.Force);
}
// on ground
else if(grounded)
rb.AddForce(moveDir.normalized * moveSpeed * 10f, ForceMode.Force);
// in air
else if(!grounded)
rb.AddForce(moveDirection.normalized * moveSpeed * 10f * airMultiplier, ForceMode.Force);
// turn gravity off while on slope
rb.useGravity = !OnSlope();
}
This ius the movement script
Some of this is borrowed, some of this is custom
Actually most of this partis borrowed