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 justking14 · Oct 18, 2013 at 11:17 PM · rigidbodypositionlockconstraintsfreezeposition

holding position

I'm working on a game where you jump from platform to platform, but each time the player jumps on one it flies away. I tried locking the position with the rigidbody, but for some reason when I press play, they all unselect except for z. rigidbody.freezeRotation = true; transform.rigidbody.constraints = RigidbodyConstraints.FreezePositionY; transform.rigidbody.constraints = RigidbodyConstraints.FreezePositionX; transform.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ; This doesn't seem to work either. Any advice? P.S. There's going to be hundreds of platforms so manually programming the specific position for each one would not be possible.

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 sdgd · Oct 18, 2013 at 11:19 PM 0
Share

there are 2 ways

  • you import character controller asset and learn how they did it

  • you do it your self by getting Transform.position and when you land on that you start adding the movement of that Transform.position to your transform.position

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Oct 18, 2013 at 11:24 PM

You want to do:

  transform.rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;

Those are flags and you have to put them on together like that.

Comment
Add comment · Show 3 · 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 sdgd · Oct 18, 2013 at 11:26 PM 0
Share

what does that exactly do?

avatar image whydoidoit · Oct 18, 2013 at 11:27 PM 1
Share

That freezes the rigidbody in every position by combining the constraints. The OP was trying to do them one at a time and so actually only froze the Z position.

avatar image justking14 · Oct 20, 2013 at 04:39 PM 0
Share

So I did that, but then it started spinning so I added RigidbodyConstraints.FreezeRotationX|...Y|...Z and now my player just walks right through them as if they weren't even there. I added the class to a different cube. $$anonymous$$y player fell through it and got stuck

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

17 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

Related Questions

JS - How do I change the constraints of an object? 1 Answer

RigidbobyConstraints2D is not working in Unity 5.0.2f1 Personal Edition!! 0 Answers

Disabling rigidbody constraints in code - Freeze Position, Rotation etc 7 Answers

How do I query the RigidbodyConstraints? 3 Answers

Unfreeze Rigidbody ROTATION only 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