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 Mr_Mertz · Nov 26, 2018 at 12:47 AM · rotationpositionparentchild

How can I make a First Person Character Controller a child of a moving platform without it affecting the rotation of the Character Controller.

So, I have an array of four square platforms that rotate in a circle around a center point. They each pass by the square that the player spawns on. When the player jumps onto one of the platforms to ride it around the loop, the Character Controller becomes a child of the platform, but that means that when the player jumps onto the platform, their rotation gets switched to the platform's current rotation. I'd like the player to be able to move freely while the platform carries them around, but I can't figure out how to prevent the rotation issue and move the player with the platform without essentially gluing their feet to the it. Are there any ways to allow a player to ride the platforms while still being completely in control of their rotation? The code I'm currently using is below. The platforms are parented by a null object so that they can rotate as a single entity.

alt text

alt text

platform-adherence.png (17.2 kB)
rotating-rectangles.png (100.6 kB)
Comment
Add comment
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

1 Reply

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

Answer by GreenSerpent · Nov 26, 2018 at 02:28 AM

Maybe you can try adding how much the platform moved each frame to the player's position. This would require that they aren't parented to each other. I'll write your script so you can try this.

     public GameObject player;
     public Vector3 lastPos = Vector3.zero;
     public Vector3 changeInPos = Vector3.zero;
     public bool playerAttached = false;
     
     void LateUpdate () {
          changeInPos = transform.position - lastPos;
          lastPos = transform.position;
          if (playerAttached) {
               player.transform.position += changeInPos;
          }
     }
     
     void OnTriggerEnter () {
          if (other.gameObject == player) {
               playerAttached = true;
          }
     }
     
     void OnTriggerExit () {
          if (other.gameObject == player) {
               playerAttached = false;
          }
     }



Comment
Add comment · Show 2 · 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 Mr_Mertz · Nov 26, 2018 at 02:36 AM 0
Share

It worked perfectly. Thank you for your help. I'm new to Unity/C# program$$anonymous$$g so it's really cool that there's such a supportive community.

avatar image GreenSerpent Mr_Mertz · Nov 26, 2018 at 10:17 PM 0
Share

Great to know that it worked! Even as someone who has been using Unity for years, I look at posts constantly to help me out. You're right, the community is awesome.

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

142 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 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 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 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 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 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

Behave like another object is parent? 2 Answers

Camera follow ball along cylinder 1 Answer

Make a simple tree 1 Answer

Where to find original unity Parent/Child script? 2 Answers

How can I identify a non-uniform scaled mesh, and fix it? 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