2D Toolkit Forum
2D Toolkit => Support => Topic started by: BraveSirRobin on December 03, 2012, 09:03:15 pm
-
Hey everyone.
I am new to 2DTK, and have some experience with Unity.
So I've just created a tk2dcamera, and configured the resolution override to 1024x768 and a wildcard override.
http://imgur.com/CgRMg (http://imgur.com/CgRMg)
Next I've created an anchor in the Upper Center with no Offset
http://imgur.com/6DRKr (http://imgur.com/6DRKr)
And inside the anchor I've created a sprite.
http://imgur.com/SFp4N (http://imgur.com/SFp4N)
In the Game window the screen is doing exactly what is supposed to, regardless of the aspect ratio, which is what I've wanted and why I've set up the overrides
http://imgur.com/bQzqj (http://imgur.com/bQzqj)
However, when I look at the Scene window, the sprite is completely off of the camera, and because of that I am unable to get a tap in the sprites using raycast.
http://imgur.com/lzRvg (http://imgur.com/lzRvg)
So my question is twofold:
1) What am I doing wrong? Why my sprites are appearing off from the camera in the Scene Window? Is this why I am unable to get the raycasts
2) Getting raycasts is the correct way of detecting taps in 2D Toolkit sprites?
Thanks in advance.
-
The output is correct.
1. In the scene window, the output in the camera preview window is incorrect due to a bug in a Unity camera function, that's why there is a tk2dCamera preview window there which shows you correct output. Its been reported but still no date for a fix.
2. Raycasts are fine. The tk2dButton uses raycasts to detect clicks and that works fine with the camera.
You don't seem to have a collider on your sprite or perhaps its off screen in the screenshot - raycasts only work when you have colliders.
Edit: Also another common cause of this not working - if the collider is too big (i.e. too thick on the z axis) and it intersects the camera, raycasts will fail.