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 Nylash · Nov 14, 2019 at 04:24 PM · collisionphysicsrigidbodykinematic

[SOLVED] Desactivate pushing forces between two objects

Hi, I am currently making a 3D Tetris-like game, and I wonder if I can prevent a object to push another when they collide.

For exemple :

A is a piece already set and B the new one the player is placing.

I want B to be block by A but not pushing it.

B is kinematic and A is dynamic, I can't pass A in kinematic I need it to keep its physics.

For the moment B is a trigger so it pass through A, I want that A works like a wall for B but in the same time it has to keep its physics.

alt text

B is the moving piece there, A is the tower made by all the pieces already placed.


Solution : I used a sweepTest.

gif.gif (120.4 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
1
Best Answer

Answer by lgarczyn · Nov 14, 2019 at 08:04 PM

So if I understand correctly, you want to be able to move an object to place it, but not interact with the scene until it is dropped, right? Let's call the cube being placed A, and every other cube B.


The best way would be to disable the rigidbody of A during placement in some way (set it as trigger, turn off collisions, put it in another layer or disable the collider), and use a boxcast to verify that you are never passing through any B block.

Edit: for a mesh, a boxcast on the bounding box or a SweepTest on the collider would work.


Another way, that is very much a cheat, but would work with minimal effort if (and only if) you are using velocities or forces to move A, would be to set the weight of A very low, and of B very high.


Another way would be to set every B as kinematic during placement. Again, only works if you use velocities and not MovePosition or setting A's position directly.


The problem is that what you want is called a one-way interaction, and is only possible in Unity through kinematic objects vs dynamic. The only real way to have two dynamic objects interact is to put them in different layers, and mirror the action of the interacter (B) in the interactee (A) layer using a kinematic body. This could also work for you.

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 Nylash · Nov 15, 2019 at 01:59 PM

The boxcast is a good idea but in the end, we will get various pieces and not simple cube or rect it could be a boat or a hat, and then the boxcast will not be precise enough.


" The problem is that what you want is called a one-way interaction, and is only possible in Unity through kinematic objects vs dynamic. The only real way to have two dynamic objects interact is to put them in different layers, and mirror the action of the interacter (B) in the interactee (A) layer using a kinematic body. This could also work for you."


Actually it's what I got here. But I control the kinematic one and it's the problem I think, but I can't change that. If the piece I control is not kinematic it does strange thing and if all the pieces already placed are not dynamic I loose the concept of the game :/

For move my object I use transform.Translate to move it on a plane parallel to the camera.

Comment
Add comment · Show 7 · 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 lgarczyn · Nov 16, 2019 at 05:20 AM 1
Share

Using transform.Translate on a rigidbody is bad and you should feel bad.

To move a rigidbody as dynamic, set the velocity to your input each frame. If you use a visible cursor, you can use smoothdamp to do that.

To move a kinematic rigidbody, use rigidbody.$$anonymous$$ovePosition.


If every other object is kinematic, you're effectively pausing the game, is that so bad? Otherwise a block B could fall on the block A you are trying to place, which would make it fly around as it tries to avoid merging through, while also not being able to affect the falling block B.


Anyway just replace the boxcast by a SweepTest

avatar image Nylash lgarczyn · Nov 16, 2019 at 03:43 PM 0
Share

I will use rigidbody.$$anonymous$$ovePosition, sorry :(


Yeah, actually we want the tower to keep its physics otherwise it could cut its falling.


Hell, didn't know this thing ! It could totally do the work, I will try it !

avatar image lgarczyn Nylash · Nov 17, 2019 at 04:23 AM 0
Share

No worries, good luck.

Show more comments

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

244 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

Related Questions

Child Rigid Body collision problem 2 Answers

Realistic collisions with a kinematic rigidbody? 1 Answer

Preventing objects from intersecting with minimal physics 3 Answers

Disable rigidbody from being able to move other rigidbodies 1 Answer

Are my kinematic rigidbodies slowing my scene down? 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