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 xxTheo · Jun 24, 2019 at 08:44 AM · collidercollision detectionraycastingkinematicrestrictmovement

Restrict Rigidbody movement in the Z axis

I have an object that rotates in the Z axis. For convenience lets call it object A. When object A collides with other objects I want it to spin in the opposite direction. But because of the way force/physics work, once it collides with other objects the impact from the collision caused the object to move/rotate on other axes. I want object A movement/rotation to be completely restricted to the z-axis. The easiest to do this is to use trigger collider or set the rigid body to kinematic but then another problem arises. If I use kinematic then I'm unable to use continuous dynamic for collision detection so when object A rotates too fast it goes through other objects because simply put there's no collision. And when I use a trigger collider, its the same problem, the large movement from one frame to the next cause the object to pass through other objects.

p.s. don't tell me to use continuous speculative because that doesn't do jack shit. With that being said thank you for taking time out of your day to help me.

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 Casiell · Jun 24, 2019 at 08:44 AM 0
Share

I'm not sure if I understood your question correctly. You want an object to only rotate on axis Z? If so, you can freeze rotation on axes X and Y in the constraints part of the rigidbody inspector

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hassanyawar · Jun 24, 2019 at 11:04 AM

You seem to be using Rigidbody to some extent so why don't you use its Constraints property? You can check the Freeze Rotation for X and Y. This will only allow your rotations in z-axis. Just set them in inspector.

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 xxTheo · Jun 24, 2019 at 02:10 PM 0
Share

I already thought of that, it doesn't work, but thank you for responding

avatar image Casiell xxTheo · Jun 24, 2019 at 04:02 PM 0
Share

At this point it's pretty clear that you didn't explain your problem well enough, or the cause of your problem is something completely different than you think it is.

I want object A movement/rotation to be completely restricted to the z-axis

Answer to this is Rigidbody Constraints. What happens when you apply them?

avatar image xxTheo Casiell · Jul 01, 2019 at 07:46 AM 0
Share

This is what happens when I turn off kinematic and use constraints ins$$anonymous$$d. The object movement is no longer restricted to the z-axis. As you can see by the gif there is a slight movement in the x,y, z position which is not a problem but this slight movement becomes a big movement once the object collides with other rigid bodies

https://media.giphy.com/media/cOccjkJpojyT3f12AI/source.mp4

EulerAngleVelocity = new Vector3(0, 0, 1); Quaternion deltaRotation = Quaternion.Euler(speed EulerAngleVelocity Time.deltaTime);
rb.$$anonymous$$oveRotation(rb.rotation * deltaRotation);

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

144 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 avatar image avatar image

Related Questions

What is the cheapest way to prevent object A from going through object B 3 Answers

Using ray cast does not produce reasonable results 1 Answer

Raycast not hitting collider 2 Answers

How can I let the ray to the edge of the capsule? 1 Answer

Raycast exit point of collider 0 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