Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 J-F · Jul 17, 2015 at 04:04 PM · characterrotatetransform.rotate

Excluding Y axis rotation from a vector3 variable?

I have a character controller that is rotated by a vector3 variable using transform.up However i need the Y axis rotation for controlling the character controller and using the vector3 variable directly transform.up = myvector3variable interferes with the controls.

In this case, this appears as the character controller snapping back to its original Y-axis angle as soon as the input key for turning is released.

Comment
Add comment · Show 8
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 mconradie · Jul 17, 2015 at 04:49 PM 0
Share

I think we'll need to see some code

avatar image J-F · Jul 17, 2015 at 05:02 PM 0
Share

Use the example code i linked, as the results for my code and that are the same.

i originally used something very similar to the code in the link and i tried to fix it by doing this:

 if( Input.Get$$anonymous$$ey( $$anonymous$$eyCode.(whateveriassignedhere) ) == true )
 {
     transform.Rotate( 0, rotationSpeed * Time.deltaTime, 0 );
 }

and what the example in the link provided:

 transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed, 0);

avatar image Oribow · Jul 18, 2015 at 12:53 AM 0
Share

There is certainly nothing wrong with your code. Have just try it myself, in a test scene. $$anonymous$$ay some other bit of code mess things up, or you didnt set it up correctly. Please post more information.

avatar image J-F · Jul 18, 2015 at 12:38 PM 0
Share

$$anonymous$$ust be this part of the script that was originally made by SirGive

  void Update () {
  
      Physics.Raycast(backLeft.position + Vector3.up, Vector3.down, out lr);
      Physics.Raycast(backRight.position + Vector3.up, Vector3.down, out rr);
      Physics.Raycast(frontLeft.position + Vector3.up, Vector3.down, out lf);
      Physics.Raycast(frontRight.position + Vector3.up, Vector3.down, out rf);
  
      upDir = (Vector3.Cross(rr.point - Vector3.up, lr.point - Vector3.up) +
               Vector3.Cross(lr.point - Vector3.up, lf.point - Vector3.up) +
               Vector3.Cross(lf.point - Vector3.up, rf.point - Vector3.up) +
               Vector3.Cross(rf.point - Vector3.up, rr.point - Vector3.up)
              ).normalized;
      Debug.DrawRay(rr.point, Vector3.up);
      Debug.DrawRay(lr.point, Vector3.up);
      Debug.DrawRay(lf.point, Vector3.up);
      Debug.DrawRay(rf.point, Vector3.up);
  
  
      transform.up = upDir;
  
  }


avatar image J-F · Jul 18, 2015 at 01:23 PM 0
Share

So maybe this is more of a question about how to neglect the Y rotation in transform.up?

Im going to lock this and ask this as a separate question now that the reason for this was discovered.

Show more comments

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

26 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

Related Questions

Rotate Character Controller 1 Answer

Setting Up Vector and Still Rotating the Character 1 Answer

how to rotate my characters 1 Answer

rotate around character 1 Answer

Rotating Transform Evenly 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