Merging a prop to any part of a player

Hey people. Usually I’d apply a bonemerge with a prop and a player bone but I need to make something a bit more flexible than that.

I’m trying to make a prop attach itself to absolutely any part of a player and stick to them like glue, for instance say I was aiming at the back of a person, would it be possible to attach it to that exact location on the players body.

Before posting here, I thought of a bit of a complex way which may work using a vertex matrix and get the difference in player direction and applying that to the prop, but I think this is a bit messy and perhaps there’s a better way of achieving this?

I would post code but I need a bit of direction as to how I’d go about doing this.

I don’t know how to do this in lua, but you are better off getting 3 vertices then “attaching” the prop to the plane. Otherwise u need to consider rotation around the vertex

Yes, this is very possible. The process is called Parenting, where you can parent a prop (although a prop_physics would be stupid) to the bone of an entity.

To get an exact spot on the entity is still possible but more complex, because you need to calculate the offset of the bone position and the vector where you want the child entity to be.

I would suggest looking up Parenting on the wiki for more examples and in-depth explanation. The current wiki might not have any good examples, so try looking at this one.

I’ve managed to figure it out, it was very difficult to get working perfectly.