# How to check if which cube's face is clicked, and where?

Hey im “kinda” new to unreal, been messing around with it for about a month.

So i’m making a game that i started with threejs and decided to just make it on unreal as i didn’t like the way it functioned.
In my ThreeJS version i had a cube, with a 30x30 face and you could click on the face and would build a cube on one of the 30x30 faces depending on where you clicked at.

The way I did this was I used raycaster and got which “segment” I clicked on.
However I cant seem to find an equivalent version here on Unreal. (though possibly lineTrace could suffice)

How do I check which face im clicking on,
And how do I tell where on that face I clicked on.

There are many ways of doing it, for something quick and dirty, you can try this:

To do it better you’d use Inverse Transform Location and a bit of math to get a precise location in the local coordinates of the big cube.
The stuff above is pretty fake but gives you something to work with at least.

https://i.gyazo.com/c4f526d831af9dbf…f061d57b77.mp4

edit: another *cheesy *way of doing it with as little math as possible (and no external 3d modelling application, that is, of course) is to build a hollow 30x30x30 cube with walls made of small cubes. You can use the 2D Grid Execution Macro to do it rapidly. Now every time you click, you get all the data you need (and more, depending what you included in the building blocks). I would go this way if it was supposed to be a playing board of a puzzle game.

That I did try when i made it using ThreeJS and made it VERY laggy and low performance. So i swapped it to using a raycaster and checking where was clicked.

I do not know how well Unreal would handle this. I do plan on making this board game like, But I do not know how much performance it will drag if i did this.

Just do not make them do heavy lifting during tick. If performance is of concern, do the first thing I suggested.

Not advocating bad code practices here but blueprints are for rapid development. Have something working, see if it makes for a fun experience. If it does, refactor the code and optimise.

edit: also, look into Instanced Static Meshes