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 boddole · Feb 06, 2014 at 07:08 AM · c#rigidbodyparenting

Parenting Preventing Player Rotation

Hello everyone, I've come across a problem where parenting my player to a object prevents that player from rotating (turning), yet still allows the player to move forward and backwards. The strange thing is, I have used the same parenting method on other objects and this problem does not occur.

It would seem that the problem is somehow with the parent object itself, but I can't see any reason this object (or any object) in question would be any different from the others...

Below is the parenting script, any ideas are appreciated.

     void OnTriggerEnter (Collider other)
     {
         if (other.tag =="Player")
         {
             other.transform.parent = transform;
         }
     }
Comment
Add comment · Show 4
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 GameVortex · Feb 06, 2014 at 07:32 AM 0
Share

The parenting code is fine. We use something similar to parent the player to moving platforms. The issue is probably in the Player Controller script where the rotation happens, maybe we could have a look at that as well?

avatar image boddole · Feb 06, 2014 at 09:15 AM 0
Share

@GameVortex: I've "kind of" solved the problem by changing the player rotation method from rigidbody.moverotation to .angularvelocity.

The issue seems to stem from the parented object being paranted to a animated bone (still don't know why, but .angularvelocity solves it).

Of course, this doesn't really solve the whole problem in that the player either doesn't inherit any momentum from the parent (even slow moving objects will result in the player slipping or sliding off of them), or the player inherits too much momentum (like if the parent object changes direction while the player is in mid air, the player will still follow it), and of course trying to "un-parent" after exiting the trigger (so the player would instantly loose all momentum). Still not completely sure what to do about all that.

avatar image venhip · Feb 06, 2014 at 03:49 PM 0
Share

@Boddole Couldn't you just get the momentum of the platform the player just left and add it to the momentum of the player?

depending on where your unparenting script would be, would affect the location for this:

 Vector3 temp = platformReference.rigidbody.velocity;
 playerReference.rigidBody.velocity += temp;

I don't know if this works. I can't test it right now, but it might work.

avatar image boddole · Feb 07, 2014 at 03:27 AM 0
Share

The problem is the platform is non-kinematic, therefore it has no velocity (it will always show as 0,0,0). So you have to create a velocity (usually by taking the current position and subtracting the previous position divided by delta time. I've actually posted a question about this, but I'll post it now for your reference:

http://answers.unity3d.com/questions/633426/problem-trying-to-apply-non-kinematic-velocity-to.html

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

20 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

Related Questions

C# Need Help converting from Rigidbody to Character Controller 0 Answers

C# DragRigidbody ArgumentException: get_main can only be called from the main thread 2 Answers

C# RotateAround for 2DRigidBodies 1 Answer

RigidBody Script Conflict 1 Answer

How to check if string array contains duplicates C# 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