#Struggling to understand SmoothDamp

1 messages · Page 1 of 1 (latest)

storm rampart
#

thread for thread sake

heavy pike
#

Might as well show the whole code if youre having problems

humble cedar
#

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

humble cedar
#

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

heavy pike
#

Well first of all, having variables named moveDir and moveDirection is just confusing

#

Maybe use something like moveDirSmoothed and moveDirTarget

#

You are still normalizing the vector too. That will negate any smoothing

#

If the problem is related to rotation, nothing here does it

humble cedar
#

I found the issue

#

the character model turning is actually in my camera script LEL