Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - richardo

Pages: [1]
1
it's ortho and 1 cam
Are you using a perspective / ortho camera? Do you have more than one camera in the scene?

Thank you I finally got it working but I'm completely didnt know what I did, and for some reason this line :
   tilemap.GetTileAtPosition(tk2dCamera.Instance.camera.ScreenToWorldPoint(e.mousePosition), out xx, out yy);

The yy var gives the inverted position of Y axis, so I have to add * -1 on that part and it's works good now. So im sure it has to do with the camera?

2
Support / having problem in finding tile coordinates through mouse cursor
« on: January 02, 2014, 05:50:51 am »
I want to make my mouse cursor shows the current tile's coordinates (the tile x and y) and display it on debug log, here is my current code

getCursorCoordinate.cs
Code: [Select]
using UnityEngine;
using System.Collections;

public class getCursorCoordinate : MonoBehaviour {

int xx = 0; int yy = 0;
public tk2dTileMap tilemap;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

void OnGUI(){
Event e = Event.current;
       
        if (e.type == EventType.MouseDrag && e.button == 0 && e.isMouse)
        {     
                tilemap.GetTileAtPosition(tk2dCamera.Instance.camera.ScreenToWorldPoint(e.mousePosition), out xx, out yy);
Debug.Log("x:" + xx + "|y:" + yy);
        }
}
}


I tried to check the most bottom left tile (where it should be 0, 0) but it shows the wrong tile coordinate (0, 28). Can anyone help me, thanks!

Pages: [1]