Hello Guest

Author Topic: Creating sprites at runtime. (Rotations)  (Read 3859 times)

JakeTBear

  • Newbie
  • *
  • Posts: 10
    • View Profile
Creating sprites at runtime. (Rotations)
« on: January 23, 2014, 12:59:34 am »
Hello,

I noticed something strange happening, my drawings were being clipped on the right side of my camera, I didnt know why this happened, so I checked their transforms and they were slightly rotated in the Y axis.

This is odd, it only happens when creating a prefab that contained a tk2dsprite in it, this is how I created them:

TargetObject = GameObject.Instantiate(PreFabClone, new Vector3(X, Y, Z), Quaternion.identity) as GameObject;

the PreFabClonewould be set in the editor, etc. the thing is if I manually set the rotation to 0, this fixes the problem but I dont understand why would it do that to begin with.

Any help would be appreciated! thank you.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Creating sprites at runtime. (Rotations)
« Reply #1 on: January 23, 2014, 11:19:56 am »
tk2dSprite doesn't manipulate the position at all, so it couldn't be modifying that.
Try GameObject.Instantiate(...);
then set position
and set rotation to quaternion.identity after that

Sounds very much like unity screwing something up here.

JakeTBear

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Creating sprites at runtime. (Rotations)
« Reply #2 on: January 23, 2014, 07:42:52 pm »
I will do that, thanks! :)

if I happen to find out the reason this happens I will post it here.

JakeTBear

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Creating sprites at runtime. (Rotations)
« Reply #3 on: January 23, 2014, 08:18:53 pm »
Found the culprit, for some reason when instantiating any prefabs with playmaker and not specifying a rotation it will set them to 0.99 in the Y, nothing to do with 2Dtoolkit, thanks though!