Stick to surface?

How do I make an object stick to another one when they collide? (ie sticky grenades, mines, “oddjob hat” sticking to where it hits a person) I assume that it is something to do with Physic Surfaces, but because I’m not too experienced in that area, I would appreciate any help anyone can lend me.

I took a screenshot of a physic material which is sticky. You should be able to attach that to a grenade.

You should probably also make the collision sphere larger otherwise the collider will penetrate.

Another solution would be to add forces along the normal of the surface you are colliding with from inside the OnCollisionStay function.

10120--369--$sticky_138.jpg

Ok, I tried the physic material, and without it, the grenade acts fine (but doesn’t stick, of course). With it, it will go through any material it hits, no matter the size of the collider. I’m not exactly clear on what you are suggesting for the adding forces bit: do you mean add force to the sphere to hold it where it is?

Actually an interesting idea with those sticky grenades. Couldn’t resist trying it out.

See the attached script.

The script presumes that you will attach it to a projectile which also has a rigidbody attached.

When hitting rigidbodies it will connect itself with a fixed joint.
When hitting other colliders or the character controller it will follow it by modifying the transform.position to always maintain the same offset to the sticked to surface.

I am sure there are simpler ways to do it but this is probably the most robust way to handle it.

10302–376–$stickygrenade_631.js (1.35 KB)

Sweet! The script works great. Thanks again for the help.

It’ been up a while but i found it today and made good use of it.

Thanks for the script.

I’ll try to ad a remote detonate funktion