Hello Guest

Author Topic: tk2dCamera Anchor Question  (Read 3794 times)

Arnold

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 32
  • Create something you love!
    • View Profile
tk2dCamera Anchor Question
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera Anchor Question
« Reply #1 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.

Arnold

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 32
  • Create something you love!
    • View Profile
Re: tk2dCamera Anchor Question
« Reply #2 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!