Jump to content
Unity Insider Forum
Sign in to follow this  
Crashdash

Dont Clip

Recommended Posts

Und ich bin's wieder. :D

 

Habe jetzt versucht, meinen Character davon abzuhalten, steile wände hochzulaufen. Mal wieder kläglich.

// X and Z first. We don't want the sloped ground to prevent
                // Player from falling enough to touch the ground.
                Vector3 displacement;
                displacement.x = velocity.x * Time.deltaTime;
                displacement.y = 0;
                displacement.z = -PlayerController.transform.position.z;
                characterController.Move(displacement);
                // Now Y
                displacement.y = velocity.y * Time.deltaTime;
                // Our steepest down slope is 45 degrees. Force Player to fall at least
                // that much so he stays in contact with the ground.
                if (-Mathf.Abs(displacement.x) < displacement.y && displacement.y < 0)
                {
                    displacement.y = -Mathf.Abs(displacement.x) - 0.001f;
                }
                displacement.z = 0;
                displacement.x = 0;
                characterController.Move(displacement);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×