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 /
  • Help Room /
avatar image
1
Question by WestBayGC · Oct 23, 2020 at 03:14 AM · physicscontrollercolliderscollision detection

[RESOLVED] Two rigidbodies not colliding (even with traditional fixes, e.g. raycasting, collision detection)

I'm new to Unity and trying to figure out what would seem to be a basic physics problem but it has me stumped, even after spending days researching various forums and boards.

I'm trying to prototype a simple foosball-type game where a rod with a paddle attached to it rotates (by player input) and knocks the ball away. But instead, the ball and paddle hardly interact at all. alt text


The Inspector Details:

  • The rod is the parent, has a rigidbody and is set to kinematic. It contains a capsule collider. Collision detection is set to continuous speculative. (Yes, I'm aware it's more costly for the physics... I'm just trying desperately to solve my problem).

  • The paddle is the child, has a rigidbody and is also set to kinematic. It contains a box collider. Collision detection is set to continuous speculative.

  • The ball has a rigidbody and is affected by gravity (and is obviously not kinematic). It contains a sphere collider. Collision detection is set to continuous. It also contains physics material for bounce.


    The Scripting Details:

  • The rod contains the main controller script (moving left or right and rotating forwards or backwards) which is based on MovePosition/MoveRotation.

  • The paddle contains a script that's supposed to add force to the ball on collision (though to be honest, I'm not sure what it's doing).

  • All three gameobjects (i.e. rod, paddle, ball) contain Daniel Brauer's DontGoThroughThings script that I found during my research but it doesn't seem to be working in my case.


    Here's The Code:

PlayerController alt text


What Am I Doing Wrong?

I'm at a dead end in terms of troubleshooting.

I thought maybe it's a collision detection issue because the paddle is moving too fast. But can that still be the case with both the DontGoThroughThings script and Continuous (Speculative) collision detection applied to everything?

Alternatively, I thought I might be using the wrong code to move the player (I'm so new to Unity, I was using the transform.translate function to move the rod at first, LOL). But after researching, it seems like MovePosition or AddForce are the two best options for rigidbody objects.

Thanks in advance for any and all help!

,

playercontrollerone-code.png (35.4 kB)
ezgifcom-gif-maker1.gif (512.2 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

2 Replies

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

Answer by WestBayGC · Oct 31, 2020 at 06:26 AM

I finally solved the issue, for anyone who stumbles on this question later:

//There were TWO problems; one code-based, the other inspector-based.

//First, I scripted both input and movement in Update. The correct method is to write the input code in Update but write the movement code in FixedUpdate... because, physics. (Yes, I know the code below is awful... I'm still learning to program...). alt text Here's a YouTube video explaining the concept:

https://www.youtube.com/watch?v=MfIsp28TYAQ

The new code solved the issue of the rod itself not acting on the ball with physics. However, that did not solve the problem visualized in my original GIF of the paddle not interacting with the ball.

Which leads me to...

//Second, I had two rigidbodies on a compound collider (i.e. both the parent-rod and the child-paddle had rigidbodies). I had to remove the rigidbody on the child-paddle and now it interacts as expected with the ball in a physics-based manner.

Here's the Unity documentation discussing this issue:

https://docs.unity3d.com/Manual/CollidersOverview.html


capture.png (42.5 kB)
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 f1uke · Oct 30, 2020 at 10:26 AM

I have the exact same issue. The DontGoThroughThings helped me with collision detection, but there is also a speed issue I think. With lover speeds, the to two objects interact more with each other. With higher speeds the two objects hardly interacts. I am using a rigidbodies and physics to fire a bullet, but it's not working at high speeds. Raycasting is not a solution for me, because I need the bullet traveltime. I have also been searching for a solutions for days, but still no luck.

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 WestBayGC · Oct 31, 2020 at 06:33 AM 0
Share

Hi @f1uke. Sorry, I'm completely new to Unity/game dev/program$$anonymous$$g myself and have no idea how to help. I'm guessing your problem is more of (what I call) an "inspector"-based issue than a code issue. But I could be wrong. It turns out I didn't need the DontGoThroughThings script on my paddle because it wasn't even supposed to have a rigidbody (see my answer to my own question). However, I still have that script on the rod. If you made it as far as finding the DontGoThroughThings script on your own, it seems like you've already seen the stuff that I would have thought could be useful for you. But please let me know if/when you find the solution, because it's likely I'll need it at some point in the future, too. Good luck!

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

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

Spawned objects sink through ground, when over 3 clones 0 Answers

Collisions without colliders 0 Answers

GameObject not colliding properly with a collider! 3 Answers

How i prevent 2 obejcts with kinematic checked in both rigidbodies collide? 3 Answers

[SOLVED] Colliders aren't working properly. Clipping through ground. 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