- Home /
Top down tile based detection
Hi all and thank you for these invaluable forums.
In a nut shell.. I've been learning Unity for about 2 months and created a few test projects. a little space flight one and an orb puzzle game. No problems.
I made a tile based mesh with textures in a top down view and I can move a selector cube around with a mouse. I can debug the correct the tile number and data back no problems using the input.mouse to point my ray.
Question: I added a little 2d guy that moves around using the keyboard, great, but how do I now get the same information for the man concerning tile data that my input.mouse ray gave me.
I naively thought I would be doing some kind of Raycast from the player to the tiles but I am almost convinced that's very wrong. If someone can point me in the right direction I really would be eternally grateful. I use c#. I didn't add the code as it's the theory I believe I'm failing.
I am almost convinced that's very wrong.
Raycast() will solve this problem. Not sure enough of your game, but if it is a regular grid, you can just find the information based on the xz position of your object.
Thanks robertbu, I finally figured out the raycast. It is working now and yes it is a regular grid. Thanks again
Your answer
