Unity2D, place GameObject at the top of another GameObject
I have a Game Object (Character) that contains a created character from multiple sprite. I want to place it at the top of the ground (Floor). i.e. bottom point of the character should be placed at the top point of the floor.
How do i accomplish this?
I'm already tried:
1) Scale is important there because Character Game Object is 0.7 scale (x and y).
this.transform.position = new Vector3(
this.transform.position.x,
this.ground.transform.position.y / 2 / this.transform.localScale.y,
this.transform.position.z
);
2) Something about pivot? Looks like pivot of the character is center. Howerver, i don't find any way to change the pivot of entire game object.
3) It doesn't acceptable to me doing this work through Unity Editor. In this case i can't accomplish accurate results.
My hierarchy:
Your answer
Follow this Question
Related Questions
Changing positions of all GameObjects in an array 0 Answers
Converting a pixel coordinate to a unity unit coordinate? 1 Answer
Problems with positioning game objects 0 Answers
Select Object And Spawn it 1 Answer
My collider2D don't work 1 Answer