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 Nanou · Feb 13, 2015 at 12:12 PM · rotationrigidbodycharactercontrollerconstraints

How does one constrain rotations of a CharacterController without a Rigidbody?

Hello,

I'm working on a player character and a follower character (the follower follows the player around), based on the 3DBuzz Third Person Character Controller Tutorial. I haven't followed the tutorial myself, but instead I received the files from someone who did.

For the following of the follower I use a simple transform.LookAt() and then use the controller to move the character forward. None of the characters in either my scene or the tutorial files are using a Rigidbody, but in the LookAt of the Follower I tell it to ignore the X rotation of the Player. Like this:

 transform.LookAt(new Vector3(0, otherCharacter.transform.position.y, otherCharacter.transform.position.z);

Now my problem with this is that the Follower will only look to the left, as if it ignores the other axes too. When I tell it to ignore the Y axis, it rotates almost correctly, is able to follow you around just fine, but when the Player's Y-position gets greater than the Follower's, it will still look up and down, which I don't want it to do. Attaching a Rigidbody won't actually do anything, since when I let it use gravity, it'll fall through the floor (even tho it has the CharacterController, and thus a collisionbox), and if I take the gravity out, the constraints won't do anything.

This is the Walk() function I made for the follower, it is called whenever the Follower is indeed the follower (since the player can switch between playing the Player and the Follower)

         void Walk()
         {
             transform.LookAt(new Vector3(0, otherCharacter.transform.position.y, otherCharacter.transform.position.z));
     
             if (Vector3.Distance(transform.position, otherCharacter.transform.position) > 2)
             {
                 follow = true;
             }
             if (Vector3.Distance(transform.position, otherCharacter.transform.position) < 2)
             {
                 follow = false;
             }
     
             //VAxis and HAxis are the equivalent of the Vertical and Horizontal axes called when using the D-pad to control the character.
             if (follow)
             {
                 Controller.VAxis += Time.deltaTime;
             }
             else
             {
                 Controller.VAxis -= Time.deltaTime * 3;
             }
     
             Controller.VAxis = Mathf.Clamp(Controller.VAxis, 0, 0.9f);
         }

So now my question is: How can I fix this?

If there's anything you need from me, just tell me. I hope anyone can help.

Comment
Add comment · Show 2
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 chariot · Feb 13, 2015 at 12:28 PM 1
Share

Rotation without rigidbody

 transform.rotation.eulerAngles


avatar image Nanou · Feb 13, 2015 at 12:51 PM 0
Share

I am so stupid. Thanks :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rigidbody constraints not working with parent/child relationship 2 Answers

Unfreeze Rigidbody ROTATION only 1 Answer

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

Rigidbody Constraints vs MoveRotation 0 Answers

Player model Rigidbody keeps falling upsidedown 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