# &quot;Padded objects&quot; type collision .. any ideas?

You wake up in a room with padded walls …

Imagine a 1 meter block colliding with a large wall in Unity. They both have typical say metal-like PhysicMaterials.

In this example, picture SLOW movement and collisions. (Like the spacecraft floating around in 2001…)

Obviously, nothing happens until the moment something touches, and then PhysX correctly provides I suppose

That’s all great … Now imagine if both objects were covered in padding, say about 5 cm or 10 cm thick.

The collision would be quite different (I think??!) - sort of squidgy, slowing down after the padding started to interact.

Has anyone done this. or can think of a good approach, or does it exist already?

My only idea was to: add a manually force field that extends 5+5 = 10 cm from the wall in the example, and ends abruptly. (I guess, implement this simply with yet another collider, as a trigger). Inside that “quantum of rubber padding” I guess you would just simply add a fixed force pushing the cube away {questions arising, would it vary with distance, or not even - how do padded walls behave?}. I suppose, it would slow it down more on the way in and speed it up more on the way out.

An extreme example - imagine throwing a ball towards a very powerful fan blowing air. That would eventually stop the ball and push it away - a kind of a bounce. I suppose, that’s sort of like the solution I describe.

Or, would it be best to use the mechanism I describe, just alone without a normal collision?

Or .???

I was also thinking, is it essentially a matter of “delaying” collision. The object comes in, PhysX does everything normally, but it “hangs in space” for a few beats before firing off in the other direction. In fact, does that achieve the right feel?

Furthermore – in fact, DOES PhysX currently do what I describe? Q, does PX wait until the moment of contact (allowing for the penetration values etc) to apply forces, or, does it start doing them when they cross some threshold and apply them over a small distance? I guess this knowledge would be critical to the issue I am asking about. (if you simply tuned that range to be bigger, that would presumably exactly achieve what I am describing.)

I also thought about arranging it so that the wall is actually a big thing which is spring’d to a real wall behind! Will springs work like that in PhysX, ie, something hitting or perhaps sitting on a object, which has a spring connection, will in fact “work” that spring? forces and events carry through to springs?

thanks for any ideas !

Hi, I was going to work on something similar to this in my project, I just didn’t get to the part where it’s appropriate to add it in yet. Maybe we could work together on it. I was thinking about using the trigger method with Rigidbody.AddForceAtPosition but then we would have to find the correct position to add the force at. Unfortunately OnTrigger events don’t pass contact information like a normal collision event, and we can’t use a “turned off normal collision” afaik because it won’t throw events.

As far as I heard from someone else on here you could use Collider.bounds Intersects to help get an idea of where you should apply the force. To answer your other sub questions; yes I think the force magnitude should be based on penetration distance that seems accurate for padded walls, just be careful that the triggers don’t overlap!

If you get some code working on this I would be glad to swap pms with you on the subject.

I can’t believe I didn’t think of this before. I’m attaching a project file so you can test out what I’ve been working on here. Basically what we do is make a Kinematic Rigidbody parented to a non-kinematic one separated out into collision layers so that only the first can collide with the “pad layer” we then use the contact points when the kinematic version collides with the pad to apply forces to the non-kinematic rigid body, thus the object drags through the pad slowly and can sometimes even bounce off it.

I’ll need to work on calculating the force to get results more in line with a padded floor, but it certainly illustrates how this is VERY possible to do.

Hope that this has helped you out!

P.S. I wonder how you’d do this with a compound collider?