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 LW · Oct 17, 2018 at 02:53 PM · physicsrigidbodymass

Stop Rigidbody From Being Pushed By Another But Still Move With Physics

Hi,

What is the "Unity correct" way to move an object with physics but make it unmovable to identical objects in the scene?

For instance, if a character is moved by physics and can move around freely, I want it to treat other characters as immovable objects even though they have similar masses.

Thanks,

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 LW · Oct 27, 2018 at 05:10 PM

So here is the solution I ended up using if it can help anyone else:

 D = collider.position - position;
 
 velocity -= normalize(D) * Dot(velocity, D)
 

It's not perfect but it gets the job mostly done. I hope that helps.

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 MonoFlauta · Oct 17, 2018 at 03:33 PM

You can set the Layer-based collision: https://docs.unity3d.com/Manual/LayerBasedCollision.html

Basically, you set a layer for each object and in Edit>ProjectSettings>Physics you set which layer can collide with which one. If you want that two same objects dont collide. Just make sure same layer isn't active in the Layer Collision Matrix

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 LW · Oct 17, 2018 at 03:57 PM 0
Share

This is an answer to a different question, unfortunately.

$$anonymous$$y question is specifically: how do I treat some objects as immovable and still collide with time?.

- Yes, they all can move.
- No, I cannot change their mass.

avatar image MonoFlauta LW · Oct 18, 2018 at 04:19 PM 1
Share

You want an object to collide with another one (not time I guess?) but that cannot be moved by others object like if the mass was "too big" when colliding with others. If now I understood well, you should save the velocity of the rigidbody in each frame. If it collides with something that shouldn't move it, you set the speed as before the velocity as before the collision. That should be just saving the Vector3 value of the rigidbody.velocity and when colliding with something you don't want to move you, put the rigidbody.velocity = to that value you saved. You should save that value in the fixed update because is part of the physics. If that isn't yet the answer you where looking for, please provide a step to step of things you want to happen so I can try to understand better.

avatar image LW MonoFlauta · Oct 19, 2018 at 08:35 PM 0
Share

Sorry for my poor explanation @$$anonymous$$onoFlauta.

I have two characters.
They both move with physics.
When either one runs into the other it to act as if the other is immovable.

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

178 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

Related Questions

What unit is Rigidbody Mass based on? 3 Answers

Composite Rigidbodies - Mass Distribution 0 Answers

What's the Rigidbody's gravity unit? 1 Answer

Rigidbodies won't collide if mass difference is too high 0 Answers

How does wheelcollider mass factor into rigidbody mass? 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