Change object position to the target up relative position.

Hello everyone.
Here is my scene i have two objects (obj1 and obj2).
Here is a photo of the scene

So obj1 rotation is always like obj2.
And i want to change obj1 position so it be on the top of obj2 and here is the script that i used.

Vector3 wantedPosition;
wantedPosition = target.position;
wantedPosition.y = wantedPosition.y + 2;
transform.position = wantedPosition;

but it didn’t do what i want and here is what this script did photo 2

and i want something like this photo 3

Thanks for any help.

Assuming, Obj2 is a child of obj1. It looks like you want to use something like,

obj2.transform.position = (obj1.transform.forward * 2.0f);

This won’t move it above, but in front of. You could also do, obj1.transform.up * 2.0f;
That might work.

Hello again i know it’s been while since i asked this question but i finally got it working and here is the code for any one who have the same problem.
Vector3 pos = target.TransformPoint(Vector3.up);
transform.position = pos;