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 joostbos · Mar 14, 2016 at 09:42 AM · collisionphysicsspeed

physics collision speed problem

I've been struggling with physics and still, after reading documentation, watching tutorials and searching on the answers page I can't get my scene to work.

I have a light object (a fly), suspended in the air (use gravity=false) that gets hit by a moving heavier object (flyswatter). Purely based on physics I expect the light object to be swept away, so it should start moving in the same direction as the flyswatter. Well, it doesn't. Most of the times it does not move at all, sometimes it moves in the opposite direction, but slowly. It also does not seem to matter if the flyswatter moves fast or slow.

i made a simple testscene where the fly is a sphere with scale (0.1,0.1,0.1) and the flyswatter a cylinder with scale (0.5,0.05,0.5). Both objects have rigidbodies, the fly with mass=0.1, the flyswatter with mass=10, both have colliders, a sphere collider for the fly, a convex mesh collider for the flyswatter (the cylinder has a default capsule collider, but that sticks out on the flat ends of the cylinder).

There is a collision detection script on the fly and I can see that the collision is detected. but the velocities at the collision are weird: Collision detected with: Flyswatter Flyswatter velocity:(0.0, 0.0, 0.0) Flyswatter angular velocity: (0.0, 0.0, 0.0) Relative velocity: (0.0, 0.0, 0.0) Collision detected with: Flyswatter Flyswatter velocity:(0.0, 0.0, 0.0) Flyswatter angular velocity: (0.0, 0.0, 0.0) Relative velocity: (0.1, 0.0, 0.0)

I had the collision detection settings to continuous, but also changing it to discrete or continuous dynamic does not make a diifference (the collision is detected in all cases, but the velocities are wrong).

I also tried changing the Use gravity settings, to see if that might help, but it also does not make a difference.

So I hope someone can point me in the right direction.

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

Answer by Harpoon · Mar 14, 2016 at 11:42 AM

There are a few things that may cause this.

How big are the colliders? Isn't the flyswatter collider too thin to register? Also instead of using a convex mesh collider, try to give it two collider, one capsule for the handle and a box collider for the square part. You can also try to increase the physic steps.

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 joostbos · Mar 14, 2016 at 08:18 PM 0
Share

Thanks for the suggestion. I'll have a look at increasing the physics steps. But I think I found the answer (see below).

avatar image
0

Answer by joostbos · Mar 14, 2016 at 08:33 PM

I was using the transform to move the flyswatter based on Input.GetAxis("Horizontal") and Input.GetAxis("Vertical"). I know from the documentation that you should not use rigidbody.transform directly if you want to use physics. But I was using gameobject.transform, so I thought that would be ok. But it is not. Also gameobject.transform is apparently messing up physics.

When I used AddForce to move the flyswatter the collision velocity and the expected behaviour was fine.

I found this thread that uses rigidbody.velocity to move an object based on Input.GetAxis. and it refers to another thread that explains to use AddRelativeForce, with ForceMode.VelocityChange

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

59 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

Related Questions

Saving player momentum after collision with object, that is destroyed after collision 0 Answers

How to tumble player car on collision with enemy car? 0 Answers

How does Angle of collision affect velocity? 0 Answers

Audio for colliding blocks 0 Answers

Is there any way to set collider's skin width? 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