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 kromenak · Jun 13, 2011 at 05:10 PM · physicsrigidbodygravityconstraints

How can I constrain physics in all directions except one?

Hey everybody,

Got a question regarding physics in our game. We're making a 2.5D puzzle game in which most of the objects are constrained in both the Z and X directions, so that they can only move up and down. We have gravity affecting these objects so that they will fall as expected.

However, the problem we are having is that you can drag these objects around with a spring joint and sometimes you drag an object upwards when other objects are on top of it. While I want the objects above to still be affected by gravity, I want to disallow upward movement - so that dragging an object upward won't push other objects upward as well, they will just stay in place.

Is there any way to accomplish this without using kinematic rigidbodies? I suppose I want to constrain movement along every axis except for the negative y axis. I've tried clamping the velocity of the object to at most 0; while this works better, you can still push objects upwards little by little over time.

I guess my final question is, if this sort of thing would be best accomplished using kinematic rigidbodies, is it possible to simulate gravity and object collision using these?

Thanks!

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 kevork · Oct 31, 2011 at 11:22 PM 0
Share

Has anyone had any luck with accomplishing this?

3 Replies

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

Answer by kromenak · Jan 25, 2012 at 08:20 PM

Ultimately, I've arrived at the conclusion that you can't, or at least it isn't exposed in Unity. While you can attempt to apply an equal downward force, this proved to be buggy and easy enough to glitch by applying force for a long enough period of time.

Our solution was ultimately to abandon using physics for this constrained movement and program transform movement that mimics the needed behavior.

Comment
Add comment · 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
0

Answer by testure · Jun 13, 2011 at 05:18 PM

Not sure which version of unity you're using but in 3.3 they added the ability to contrain individual axis position and rotation on rigid bodies. Should be there in the rigid body inspector, and you can access it via script as well.

Comment
Add comment · Show 1 · 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 kromenak · Jun 13, 2011 at 06:41 PM 0
Share

Hey, we're using this feature to constrain movement in the Z and X directions and also to constrain rotation in the Y and X directions. However, the problem we are having is that we only want our objects to move downward - so, constraining the movement along one axis in one direction.

avatar image
0

Answer by slayzar · Feb 17, 2012 at 02:21 AM

Hey everyone. I'm having severe problems trying to get the constraints to work. I am trying this in Update():

transform.rigidbody.constraints = RigidbodyConstraints.FreezePositionY;

But I get this error: The name `RigidbodyConstraints' does not exist in the current context.

Any help would be greatly appreciated.

Comment
Add comment · 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

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

Setting a RigidBody's velocity messes with my custom gravity, not sure how to proceed. 0 Answers

Rigidbody (with Box Collider) falls through floor 1 Answer

Player in Spaceship 2 Answers

What should my gravity be if I've modeled in feet and inches in Max? 3 Answers

How To Set Individual Rigidbody Gravity [Solved] 3 Answers


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