mathematics – what is the math behind the parenting a transform in unity?

You don’t really need to know how that is implemented in math and vector functions. Not having to bother with stuff like that is one of the reasons why you are using a game engine in the first place 🙂 But if you want to know because it interests you:

Internally, Unity implements the whole data of the Transform component with a transformation matrix. A transformation matrix is a collection of 4×4 floating-point values. Encoded in these values is the translation, rotation and scale (and technically also skew, but that’s rarely used in 3d graphics).

There is a way to multiply a point (represented as a Vector) with a projection matrix which results in a new point with the rotation, translation and scale applied to it. You can also multiply two projection matrices with each other to get a single new 4×4 matrix which applies the transformations of both matrices one after another. This is how the matrices of transforms in a parent hierarchy are calculated. Unity actually exposes that matrix of a transform and its parent transforms through the property localToWorldMatrix.

OK, but how exactly does that multiplication of a vector with a matrix or a matrix with a matrix work? Lots of people have already written lots of explanations for that which are far better than I could write.