Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 iyenal222 · Sep 10, 2015 at 05:26 PM · charactermovelevelthird person controllerslope

How can I do the character parallel to geometry level

I have a character (Sonic) so I wanted him to walk while being to be parallel to the geometry level : alt text

but now it's : alt text

I use third person controller with rigidbody and capsule collider. I have tried to use Locomotion System : https://www.assetstore.unity3d.com/en/#!/content/7135; but it dont work on Unity 5. I know an asset who can do that but it's paid(PGDK) : https://www.assetstore.unity3d.com/en/#!/content/28476

I hope you can help me. Thanks

capture2.png (427.8 kB)
capture3-resized.png (27.1 kB)
Comment
Add comment · Show 4
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 Hellium · Sep 10, 2015 at 03:04 PM 0
Share

I would suggest a raycast downwards. You can get the normal to the collider the raycast hit. Then, rotate your character so that its up vector is parallel to the normal

avatar image iyenal222 Hellium · Sep 10, 2015 at 03:13 PM 0
Share

Can you give me a script please in JS or CSharp for this because I use Playmaker visual scripting

avatar image iyenal222 · Sep 11, 2015 at 06:17 AM 0
Share

I have a question : what do the raycast physics ? I read the documentation on that but I don't understand

avatar image itsharshdeep iyenal222 · Sep 11, 2015 at 06:37 AM 0
Share

It wall draw a line ( like a laser beam). That light will send you the information that 'm I hit with something or not.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Cherno · Sep 11, 2015 at 09:42 AM

 public LayerMask terrainLayer;
 public bool grounded = false;
     private Quaternion rotCur;
     private Vector3 posCur;
 
 void Update() {
 
         Ray ray = new Ray(transform.position, -transform.up);
         RaycastHit hit;
         
         if(Physics.Raycast(ray, out hit, 1f, terrainLayer) == true) {
 
             rotCur = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
             posCur = new Vector3(transform.position.x, hit.point.y, transform.position.z);
 
             grounded = true;
     
         }
         else {
             grounded = false;
         }
 
 
         if(grounded == true) {
 
             transform.position = Vector3.Lerp(transform.position, posCur, Time.deltaTime * 5);
             transform.rotation = Quaternion.Lerp(transform.rotation, rotCur, Time.deltaTime * 5);
         }
         else {
 
             transform.position = Vector3.Lerp(transform.position, transform.position - Vector3.up * 1f, Time.deltaTime * 5);
 
             if(transform.rotation.eulerAngles.x > 15) {
                 turnVector.x -= Time.deltaTime * 1000;
             }
             else if(transform.rotation.eulerAngles.x < 15) {
                 turnVector.x += Time.deltaTime * 1000;
             }
 
             rotCur.eulerAngles = Vector3.zero;
             transform.rotation = Quaternion.Lerp(transform.rotation, rotCur, Time.deltaTime);
 
         }
 
     }
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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

how can i let my player move converse? 0 Answers

how to add a walking animation when character is moving? 3 Answers

Need help getting my character to move 2 Answers

How to make a camera that moves with the player? 1 Answer

Help with plat-former character rotate 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