Local transform.forward/right/up for a child

Is there anyway to easily get a local direction, a bit like transform.forward. However imagine I child object b to object a. If I rotate the parent object (a) but not the child (b), I want a vector 3 that will still be (0,0,1) for forward and only to change when object b’s local rotation is changed.

I think what you’re looking for is the child’s forward vector in its parent’s space, rather than getting it in World space.

So you would do this (in a script attached to the child):

transform.parent.InverseTransformDirection(transform.forward);

So if the child is pointing in the same direction as the parent, you’ll get 0,0,1. If you rotate the parent, that number won’t change. If you rotate the child, say to 90 degrees around Y, you’ll get 1,0,0 regardless of how the parent is rotated.