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 shadowpuppet · Jun 04, 2015 at 02:21 PM · platforms

toggle rigidbody constraints?

I am going nuts with this elevator thing. I can only get the player to ride it is if "Is Kinematic" and "Y constraints" are unchecked. But then the player just is a mess in the world randomly changing heights. I have tried to play with gravity thinking that would solve it but no. This is the Ethan Character from the Stealth tutorial and I have the same settings as the tutorial.Is there anyway to toggle theses settings on the fly? I tried to make the player a child of an empty game objects to access those variables in an animation( since player itself is read only). Kinematics enabled was an option but there was no animation channel for the constraints

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

Answer by Cherno · Jun 04, 2015 at 02:40 PM

The way rigidbody constraint toggling works is a little weird; here is a decent explaination:

link 1

link 2

Comment
Add comment · Show 8 · 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 shadowpuppet · Jun 05, 2015 at 08:22 AM 0
Share

well the first link was dead but the second is on the right track. However all the examples are about turning a constraint on. I need it turned off. I guess I'll fidd;e with inserting a "faalse" comment in there somewhere. but thanks, that was helpful as those scripts do indeed work for turning the constraint on when I enter the trigger zone with the players Y position constraint unchecked - I watch it happen in the inspector.

avatar image Cherno shadowpuppet · Jun 05, 2015 at 11:31 PM 0
Share

The link works, it was just the formatting syntax I got wrong. I corrected it.

avatar image shadowpuppet shadowpuppet · Jun 05, 2015 at 11:50 PM 0
Share

seriously how do you add a new comment, this is my fourth try - all rejected. how is anybody suppose to thank anybody

avatar image shadowpuppet shadowpuppet · Jun 05, 2015 at 11:53 PM 0
Share

oh, that worked. I got the code to work. In that link I didn't notice that the code actually continued and didn't scroll right to see the ret of it where the "|" allowed you to list multiple constraint properties on the same command. I was doing it each on their own line and it was like playing whack-a-mole with the little checkboxes. By saying "freeze this" it assumes you want everything else unfroze

 function OnTriggerEnter(other : Collider)
  {
     if(other.gameObject == player)
      {
                 player.rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
         AudioSource.PlayClipAtPoint(liftSound, transform.position);
     
       }
  }    
      
     
  function OnTriggerExit(other : Collider)
  {
     
      if(other.gameObject == player)
      {
          
           player.rigidbody.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY; 
          
           
      }
  }  
Show more comments
avatar image Cherno · Jun 06, 2015 at 12:14 AM 0
Share

I converted your answer to a comment.

If my answer was indeed helpful, please consider flagging it as accepted so it helps other users with the same problem.

avatar image shadowpuppet · Jun 06, 2015 at 12:24 AM 0
Share

absolutely, I was looking for that, where can I flag it?

avatar image Cherno · Jun 06, 2015 at 12:55 AM 0
Share

Just click on the chevron thingy below the two thumb icons.

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

Vector3.lerp and Mathf.pingpong not moving smoothly 3 Answers

Is there away to develop for the Kindle Fire with Unity? 1 Answer

Make a platform disappear after the next one appear 2 Answers

Player Bounces On Ascending Platform After Platform Velocity Is Updated 0 Answers

How do u get the platform to stick? 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