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 Kthieu · May 17, 2014 at 07:59 AM · charactercontrollerrotateraycasthitnormalsorientation

Unity Third Person Character Controller(Standard Assets ver) Orient to Normal and keep its rotation from movement?

Hello. I'm using the standard assets Third Person Controller that comes with Unity for my group's game and we are trying to get a rotation towards the normal. In the update function, I have the following for what I thought is the correct approach to rotation. I'll fix the smooth interpolating later as this is testing code. I've been looking at the following link for help. http://answers.unity3d.com/questions/168097/orient-vehicle-to-ground-normal.html

    if(IsGrounded()) {
     var turn : float = Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime;
     
     curDur = (curDir + turn) % 360; 
     if (Physics.Raycast(transform.position, -curNormal, Rayhit))
     {
         curNormal = Vector3.Lerp(curNormal, Rayhit.normal, * Time.deltaTime);
         var grndTilt : Quaternion = Quaternion.FromToRotation(Vector3.up, curNormal);
         transform.rotation = grndTilt * Quaternion.Euler(0, curDir, 0);
     }
     }

Now, I'm still looking at the controller and its movement calculation. Still, when this code is inserted in the update(), the object DOES rotate to the normal, albeit clunky, but the rotation based on its turning or its current forward direction doesn't apply anymore.

My guess is in Quaternion.Euler. I'm still confused as to how this works aside from its relation to rotating the object. The arguments of 0 may have something to do with it. Please help me. Note that I did not change anything involving the character controller's movement aside from its variables.

Comment
Add comment · Show 1
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 Kthieu · May 17, 2014 at 09:06 AM 0
Share

Would multiple calls to transform.rotate in the same update function cause trouble? There is a call if the player is grounded for the player to call transform.rotate on itself to face its moveDirection using Quaterion.LookRotation

Again, little to nothing has been changed with this default controller. So one can look at the default controller and give me advice.

Also, our player is a model from the NASA 3D models page, so no animations are necessary; just a simple mesh renderer was used. The player does rotate and move without this code, but once I included it, the orientation happens, but the rotate towards the player's forward no longer works.

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Unity Character Controller How to push yourself away from walls or steep slopes? 0 Answers

Basic movement. Walking on walls. 8 Answers

Make Gameobject Stand On Surface Facing Certain Direction 0 Answers

How to make Character Controller Rotate see-saw type object below due to both weight and fall speed of character? 0 Answers

Change gravity point on trigger 0 Answers


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