# Applying force to just one of two colliding objects

Discussion in 'Physics' started by Lukazos, May 2, 2019.

1. ### Lukazos

Joined:
Jan 11, 2018
Posts:
5
So here's the deal. We are creating a game where you play as a giant and destroy houses. The houses are split into pieces when they interact with the giant and it works for the most part. But I want the giant to run smoothly through the houses which don't really work due to so many rigidbodies colliding. Is there a way to make the giant not interact with the house pieces but the pieces interact with the giant? Kinda like a one-sided collision.

I've tried making the difference in mass as big as possible but to no real effect.
but again, no real difference.

A video showing what it looks like when they collide at the moment.

2. ### srivello

Joined:
Jan 16, 2011
Posts:
16
Good question.

If you want object 'a' to collide with object 'b' but not vice versa you can use layers. Add a to layer a and b to layer b, then in the project settings UNCHECK that b collides with a.

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

Joined:
Oct 14, 2013
Posts:
723
I don't think selective collisions will help on its own-- we still need the building pieces to collide with the giant, and there is no way to turn off one "side" of the collision with the collision matrix. Physics.IgnoreCollision is a similar story.

The manual mentions that large mass differences may cause some instability. What mass values did you try? Did you experiment with a lot of different values, or only extreme values?

Something you might try is to pair the Collider's on the body parts with kinematic Rigidbody's. If you can't make them kinematic because they need to be able to be influenced by other things, then you could add a set of subchildren to each body part, each with another Collider and a kinematic Rigidbody whose only purpose is to knock stuff down. Assign layers and define the collision matrix so that these will interact with only buildings, and turn off collision with buildings for the first set, and collisions between the two sets. This may lead to other complexities, but I think it should be manageable.

Hopefully there isn't something more obvious that I'm not considering.

Lukazos likes this.
4. ### Lukazos

Joined:
Jan 11, 2018
Posts:
5
Thank you for the Answers. I managed to solve it on my own using some trickery with layers. I basically made the giants own collider not interact with the house pieces, then I created new colliders as children of the giant and just set the position of those to the different parts of the giant. This created the desired effect. Hope this can work as a possible solution for others in the future.

File size:
284.7 KB
Views:
162