Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 unity_eKM12ISct89KKw · Sep 24, 2021 at 12:10 AM · rotationrigidbodycolliderball

Non-rotating collider fixed to a rolling ball

So, in my game the player is basically on top of a ball that gets rotational acceleration applied to it and rolls. The ball has a rigidbody and a sphere collider, and I like the movement of the ball so far.

I would like the player to have a collider so the ball can't roll under a gap or something and have the camera pass through walls. I'm having trouble with the collider representing the player (the capsule on top of the ball). alt text

Because the ball rotates, I can't simply make the collider a child of the ball, as the collider would rotate with it. I've tried using scripts to fix its rotation and position above the ball every Update and FixedUpdate, but it either creates horrible jitter or just passes through walls as if the collider isn't there.

The closest I've come is by using joints. I've managed to fix the position and rotation above the ball, but the problem with this is a rigidbody has to be attached to the capsule, and so it has to have mass. With a mass comparable in size to the ball's, the ball has to pull along the capsule and starts and stops sluggishly. If the mass of the capsule is very low, at high speed collisions it just gets pushed around and doesn't stay where I'd like it to be:

alt text

I've messed around with articulation bodies, but they don't seem to have options that allow the collider to stay where it is relative to the parent and not rotate.

So, does Unity have some feature that would allow my capsule collider to stay with the rotating object in this way? If not, I will get to scripting and try to work something out with Physics.OverlapCapsule or something. Just want to check if anyone can help me with a solution I haven't considered.

Thanks

capture1.png (143.6 kB)
capture2.png (48.1 kB)
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 AlgoUnity · Sep 24, 2021 at 07:03 AM

Thats an interesting problem I feel like there must be a good solution, at first I was thinking to have a parent object that both the ball and capsule are attached to, but you want to use the angular velocity of the ball as the means of movement which makes things complicated.

I do have a crazy idea though, what if you attach 4 children to the capsule and put box colliders on them, these boxes would basically surround the ball such that they are barely outside of its reach and aren't colliding with the ball. Then you make these box colliders not be able to collide with anything other than the ball using layers, so they can go through walls and everything else but the ball cannot go through them. That way when the capsule hits something, the ball gets stopped by the 4 box colliders under the capsule and the ball will never be able to move away from under it.

Seems a bit hacky but that's all I can think of.

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 unity_eKM12ISct89KKw · Sep 24, 2021 at 08:58 AM 0
Share

Huh, that is a wacky but clever solution, lol. I've made considerable progress on this through scripting (basically, checking if the capsule is overlapping with anything, manually setting the corrected position, linear/angular velocity of the ball, and calling Physics.SyncTransforms()). There's a little bit of jitter, but with some tweaking it could work.

As for a solution using colliders, yeah, I feel like there should be some simple way of doing it, but I'm just not seeing it. I will definitely give your box method a go and report back. Thanks!

avatar image unity_eKM12ISct89KKw unity_eKM12ISct89KKw · Sep 24, 2021 at 09:26 PM 0
Share

Unfortunately, no matter how I meddle with the settings of the box colliders, the ball just passes right through them if they're children of the capsule. alt text

Despite the fact that if I separate the boxes from the capsule, the ball collides with them just fine.alt text

Good idea, though.

capture4.png (326.2 kB)
capture5.png (422.5 kB)
avatar image AlgoUnity unity_eKM12ISct89KKw · Sep 25, 2021 at 02:41 AM 0
Share

I think you might be able to have the boxes use a separate RigidBody from the capsule and have them follow the capsule with a script on FixedUpdate, instead of being children of the capsule. That just makes the solution even more hacky though haha

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

229 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 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

Grabbing a handle in VR and rotating it like a crank? 1 Answer

Rigidbody doesn't rotate after collision 3 Answers

Propelling a Ball 1 Answer

NavMeshAgent with Non-Kinematic Rigidbody possible? 0 Answers

Get angle from impact 2 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