Hi,
Is there any method to retrieve an instance of the class tk2dSprite using a Collider?
By default a collider can return a game object but not a sprite. I'm using the below code to drag sprites, which works nicely, however the object returned by the function hit.collider.gameObject is of type GameObject, not tk2dSprite. If I change the object obj to be of the type tk2dSprite and cast the object returned by hit.collider.gameObject to tk2dSprite the code returns an error. Is there any other method to reference the sprite detected by a collider?
GameObject obj;
if (Input.GetMouseButtonDown(0)) {
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray,out hit))
{
obj = hit.collider.gameObject;
}
}