• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ReginTheSmith · Feb 16, 2021 at 05:11 AM · charactercontrollerjumpwallwall jumpwalljump

3d wall jumping with charter controller

im making a 3d Platformer with unity's built-in charter controller and no mater what I try I can't seem to get wall jumping right. The player jumps but he doesn't jump off the wall to the opposite side he just stays on the wall. NOTE: this is not the entire script because the script is too long to include it all so I only included the parts that involve the wall jump. This is what I have:

 void OnControllerColliderHit(ControllerColliderHit hit)
     {
         hitNormal = hit.normal;
     }

 void WallJump()
     {
         velocity.y = Mathf.Sqrt(maxJumpHight * -2 * gravity);
         animator.SetBool("Jumping", true);
         wallJumping = true;
         woosh1.Play();
         jump.Play();
         movingPlatform.enabled = false;
         canMove = false;
         StartCoroutine(CanMoveAgain());
     }


 float horizontal = moveing.x;
         float vertical = moveing.y;
         Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
         
 
         if (direction.magnitude >= 0.1f && canMove)
         {
             if (wallJumping == true)
             {
                 direction = -hitNormal;
                 controller.Move(hitNormal * speed * Time.deltaTime);
             }
             if (!wallJumping == true)
             {
 
 
 
                 float targetAngle = Mathf.Atan2(-direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
                 float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
                 transform.rotation = Quaternion.Euler(0f, angle, 0f);
 
                 Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
                 controller.Move(moveDir.normalized * speed * Time.deltaTime);
             }
         }

it just doesn't work what do I do?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MUG806 · Feb 16, 2021 at 09:08 AM

Edit: Think I found your problem. In WallJump you do:

canMove = false;

but then your code to move in the direction of the wall normal is inside this if statement:

if (direction.magnitude >= 0.1f && canMove)

which requires canMove to be true. You either need to change the if statement, move the wall jump code outside of it, or not set canMove to false.

Old wrong answer:

I see you've written a "WallJump" method which looks fine, but I dont see you actually calling it anywhere. Is there some code you haven't included where you trigger your wall jump to happen? If not I think you just forgot to do that. Somewhere when you detect if the player is against a wall and trying to jump you need to have the line:

  WallJump();
 


Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ReginTheSmith · Feb 16, 2021 at 02:32 PM 0
Share

no its there I just didn't put the whole script

avatar image MUG806 ReginTheSmith · Feb 16, 2021 at 02:42 PM 0
Share

I imagine your problem is in that section of code, so if you don't include it I can't really help.

avatar image ReginTheSmith MUG806 · Feb 16, 2021 at 11:40 PM 0
Share

I know it's not the problem cuz I jump but I don't jump off the wall but here:

getting the input:

 private void Awake()

 {
     controls = new PlayerControls();

 controls.GamePlay.Jump.performed += ctx => Jumping();

 controls.Extra$$anonymous$$ovement.GroundPound.performed += ctx => TriggerButton();

 controls.Extra$$anonymous$$ovement.GroundPound.canceled += ctx => TriggerButtonCanceled();

}

checking if I can jump:

 void Jumping()
     {
         var hitAngle = Vector3.Angle(Vector3.up, hitNormal);
 
         if (isGrounded && canWalkOnSlope)
         {
             Jump();
         }
         else if (isGrounded && !canWalkOnSlope && hitAngle >= 71 && hitAngle <= 110)
         {
             WallJump();
         }
     }


and jumping:

 void WallJump()
     {
         velocity.y = $$anonymous$$athf.Sqrt(maxJumpHight * -2 * gravity);
         animator.SetBool("Jumping", true);
         wallJumping = true;
         woosh1.Play();
         jump.Play();
         movingPlatform.enabled = false;
         can$$anonymous$$ove = false;
         StartCoroutine(Can$$anonymous$$oveAgain());
     }




Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

132 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity2D Platformer - Wall jumping with unity's physics 1 Answer

HELP! stuck on wall jump Unity 2D 1 Answer

Jump and Hold on!! 0 Answers

I'm trying to make a 3D player do a wall jump. Does anyone have advice? 0 Answers

Jumping away from a wall 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges