#Third Person Character Controller

1 messages · Page 1 of 1 (latest)

pastel condor
#

Did that actually work? you seem to be using my older version(where i mistakenly put it in the grounded code). Anyways have an if statement that checks if num jumps is == to 2. If it is then set Gravity to a larger number. Reset both numJumps and the gravity in the same place where the if statement with the comment // stop our velocity dropping infinitely when grounded

pastel condor
pale goblet
#

In my if statement I did

#

if (Grounded && numJumps < 1)
{
}
else if (!Grounded && numJumps < 1

#

And I don’t exactly remember what else I changed but that worked

pale goblet
#

gravity is -9.8

#
private void JumpAndGravity()
        {
            if (Grounded && numJumps == 0)
            {
                // reset the fall timeout timer
                _fallTimeoutDelta = FallTimeout;

                // update animator if using character
                if (_hasAnimator)
                {
                    _animator.SetBool(_animIDJump, false);
                    _animator.SetBool(_animIDFreeFall, false);
                }

                // stop our velocity dropping infinitely when grounded
                if (_verticalVelocity < 0.0f)
                {
                    _verticalVelocity = -2f;
                }

                // Jump
                if (_input.jump && numJumps < 1)//_jumpTimeoutDelta <= 0.0f)
                {
                    // the square root of H * -2 * G = how much velocity needed to reach desired height
                    _verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
                    numJumps++;


                    // update animator if using character
                    if (_hasAnimator)
                    {
                        _animator.SetBool(_animIDJump, true);
                    }
                }
            } else if (!Grounded)
            {
                // reset the fall timeout timer
                _fallTimeoutDelta = FallTimeout;

                // update animator if using character
                if (_hasAnimator)
                {
                    _animator.SetBool(_animIDJump, false);
                    _animator.SetBool(_animIDFreeFall, false);
                }

                // stop our velocity dropping infinitely when grounded
                if (_verticalVelocity < 0.0f)
                {
                    _verticalVelocity = -2f;
                }

                // Jump
                if (_input.jump && numJumps < 1)//_jumpTimeoutDelta <= 0.0f)
                {
                    // the square root of H * -2 * G = how much velocity needed to reach desired height
                    _verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
                    _verticalVelocity -= Gravity * 2 * Time.deltaTime;
                    numJumps++;


                    // update animator if using character
                    if (_hasAnimator)
                    {
                        _animator.SetBool(_animIDJump, true);
                    }
                }
            }


                // jump timeout
                if (_jumpTimeoutDelta >= 0.0f)
                {
                    _jumpTimeoutDelta -= Time.deltaTime;
                }
                // reset the jump timeout timer
                _jumpTimeoutDelta = JumpTimeout;

                // fall timeout
                if (_fallTimeoutDelta >= 0.0f)
                {
                    _fallTimeoutDelta -= Time.deltaTime;
                }
                else
                {
                    // update animator if using character
                    if (_hasAnimator)
                    {
                        _animator.SetBool(_animIDFreeFall, true);
                    }
                }
            if (Grounded)
            {
                numJumps = 0;
            }

                // if we are not grounded, do not jump
                _input.jump = false;

            // apply gravity over time if under terminal (multiply by delta time twice to linearly speed up over time)
            if (_verticalVelocity < _terminalVelocity)
            {
                _verticalVelocity += Gravity * Time.deltaTime;
            }
        }
pale goblet
#

its more like im gliding

#

and if i can could I use rigidbody's?

pale goblet
#

@pastel condor

pastel condor
pale goblet
#

well its weird there is a pause at the top of the jump

pastel condor
pale goblet
#

but it doesnt feel natural this is at -15 gravity

pastel condor
pale goblet
#

ill see if I can slow it down

#

and untiy crashed

#

and i didnt save

#

good thing I printed the code here

#

@pastel condor nowim getting an error when reimporting the controller from the plugin

#

i found the problem

#

something is making grounded true forever

#

@pastel condor i found the problem the gravity is fine but the fall doesnt speed up like normal gravity

#

nope its something with my character

#

welp

#

well its my collision so i removed my collider and I want my own collider but it breaks if I have it

#

same with rigidbody etc