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
1
Question by chuckbergeron · Jun 11, 2012 at 12:11 AM · rotationtransformfirst-person-controllerparentingelevator

Changing the parent transform of the First Person Controller

Allo there. I'm having a strange issue when attaching a First Person Controller as a child of another transform, namely an elevator.

The parentTransform is rotated 180 degrees so as soon as the function fires, the First Person Controller rotates around 180 degrees to match it's new parent's localspace. Same thing happens in reverse, the FPC flips a 180 when it becomes relative to worldspace again.

The code looks a lil' something like this:

 private var parentTransform : Transform;

 function Start () {
   parentTransform = transform.parent;
 }

 function OnTriggerEnter( collided : Collider ) {
   if ( collided.gameObject.tag == "Player" )
     collided.transform.parent = parentTransform;
 }

I know it works like a charm when the parentTransform isn't rotated, but I'll need to set up multiple elevator instances, each with their own unique position & rotation.

Thanks!

Edit: Added Photos as visual-aide.

[1]: http://answers.unity3d.com/storage/temp/1206-before.jpg

[1]: http://answers.unity3d.com/storage/temp/1207-after.jpg

before.jpg (260.2 kB)
after.jpg (325.6 kB)
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 chuckbergeron · Jun 11, 2012 at 03:26 AM 0
Share

Here's a video showcasing the strange behaviour: http://youtu.be/403zIiyieS4

The first bit shows with $$anonymous$$oving Platform enabled, no child/parenting going on, and jittery movement.

After that, with child/parenting via script and the strange rotation issue happening in the Aux elevator instance (rotated 180 degrees).

Lastly, I go over to the working elevator (rotated 0 degrees) and it's smooth as silk.

Cheers!

1 Reply

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

Answer by aldonaletto · Jun 11, 2012 at 01:18 AM

That's a weird thing: I tested the First Person Controller and a moving platform rotated 180 degrees, but nothing wrong happened - the player entered and exited the trigger without changing its rotation, as expected. I tried all the modes in the Character Motor / Moving Platform fields, and nothing changed. Could you have some other script zeroing the FPC localRotation? Or are you using another control script (not CharacterMotor.js)? By the way, if you're using the standard CharacterMotor, there's no need to child the character to the platform - the script already provides control for moving platforms - just let let Character Motor / Moving Platform / Enabled checked in the Inspector, which by the way is the default.

Comment
Add comment · Show 4 · 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 chuckbergeron · Jun 11, 2012 at 02:10 AM 0
Share

Thanks for the reply, Aldo. There's no script that I know of zeroing the localRotation, and I'm using the default Character$$anonymous$$otor.js w/ default settings. However, the framerate goes jittery if I don't child the FPC to the moving platform. It's nice and smooth as a child, and works like a charm on the main elevator (no instance rotation). I'm uploading a video to YouTube to give a better idea of what's going on.

avatar image chuckbergeron · Jun 11, 2012 at 03:27 AM 0
Share

Video's finally ready! http://www.youtube.com/watch?v=403zIiyieS4 Also, this is in Unity 3.5.0f2 Pro with default character controller.

avatar image chuckbergeron · Jun 11, 2012 at 04:46 AM 0
Share

You were right. The 180 degrees thing doesn't seem to matter when I pull the elevator out into a brand new test project, and use complete default First/Third Person Controllers. Cheers!

avatar image aldonaletto · Jun 11, 2012 at 01:52 PM 0
Share

Glad to know it worked!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

X-Flip is making my rotation break? 2 Answers

Rotating an Object to its Original Angles after certain distance from ground 1 Answer

How do I make gameObject.transform.rotation.z equal to a set float value? 2 Answers

Moving child transform also moves parent rigidbody 0 Answers

How to unparent a Transform by UnityEvent? 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