Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 GameLvr · Oct 13, 2010 at 07:12 PM · jumpingslope

How to prevent steep wall climbing?

How to prevent steep wall climbing?

Hi, currently, if a slope is steep enough, with first person, you get stopped at it...unless you keep the forward key down and repeatedly hit jump to climb up it.

how can I prevent the player from being able to climb steep slopes without disabling jump?

I've tried experimenting with the Jumping parameters in the Character Motor script, but no luck so far

thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Michael_Berna · Aug 02, 2019 at 11:23 PM

I had the same exact problem in my game. Another user shared this code designed for allowing characters to slip down hills. I modified it and it solved my problem perfectly. Note that speed, slopeLimit, and moveDir are in the default character controller script.

 private Vector3 hitNormal;
 bool m_IsGrounded;
 private float slopeLimit;

 private void Start()
 {
      slopeLimit = m_CharacterController.slopeLimit;
 }
 
 private void Update()
 {
     if (!m_IsGrounded)
     {
         m_MoveDir.x += (1f - hitNormal.y) * hitNormal.x * (speed * 1.2f);
         m_MoveDir.z += (1f - hitNormal.y) * hitNormal.z * (speed * 1.2f);
     }
 
     if (!(Vector3.Angle(Vector3.up, hitNormal) <= slopeLimit))
     {
         m_IsGrounded = false;
     }
     else
     {
         m_IsGrounded = m_CharacterController.isGrounded;
     }
 }
 
 private void OnControllerColliderHit(ControllerColliderHit hit)
 {
        hitNormal = hit.normal;
 }


Comment
Add comment · 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
0

Answer by Adam Rademacher · Oct 13, 2010 at 07:21 PM

You'll have to implement some kind of slip code on slopes to allow the controller to move downward away from the wall. Otherwise, the basic controller will think it is grounded and use your normal movement code.

A good place to start is in detecting the normal of the point you hit at and using vector math to determine the appropriate "down" direction and mark that the player is no longer 'grounded' or whatever your controller requires before you can jump if the values of the normals are too high. The normal is perpendicular to the face of the collider, so if the Y-value of the normal is too low, your character is on a slope.

Comment
Add comment · Show 1 · 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 GameLvr · Oct 13, 2010 at 07:45 PM 0
Share

thanks, Adam I was hoping there was something in the parameters I missed :( I suppose I could use the vector check to bypass the jump input for a second or two Looks like the Character $$anonymous$$otor has a lastGroundNormal var, so maybe I can use that

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.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How can I stop the fps controller jumping up slopes? 1 Answer

Enable jump when hitting ground? 0 Answers

Prevent character from autojumping when moving down a slope. 0 Answers

How do I stop the 3rd person script from jumping up walls 0 Answers

Character controller slope limit issues 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