2D Toolkit Forum

2D Toolkit => Support => Topic started by: Arnold on October 11, 2013, 05:37:33 pm

Title: tk2dCamera Anchor Question
Post by: Arnold on October 11, 2013, 05:37:33 pm
Hey!

I'm Arnold and i'm super new to Unity coming from a small Gamemaking tool called Stencyl.
Here's my noob question.

I have my tk2dCamera setup with an child Anchor with the upper Left setting. Attached to the Anchor
i have my GameController Gameobject which sits at 0,0,1 in the Scene (upper left). Now i spawn a prefab (Sprite) via code as a child of the GameController and want to set the Sprite's position. This works but if i set the position of the Sprite to 0,0,1 it gets displayed in the middle of the Screen. My sprite is basically ignoring the tk2d Anchor. I just want to freely position my Sprite with 0,0 being top left, like in the scene view.

What am i doing wrong?
Title: Re: tk2dCamera Anchor Question
Post by: unikronsoftware on October 11, 2013, 06:08:20 pm
Set the sprite.transform.parent = cameraAnchor.transform;
Position the sprite using sprite.localPosition (x, y, z) = 0,0,0 = topleft.
Title: Re: tk2dCamera Anchor Question
Post by: Arnold on October 11, 2013, 07:12:41 pm
aha!
cool so it is a problem between global and relative aka local positions.

Thanks, something learned!