Select floor while looking down

Hello everybody.
I am working on a project where some objetc can be selected for different proposes like color/material change and mesh changes.
With the props there are no problem, I create a BluePrint Class with the model in it, and a box collision volume. I use this volume to know when the player is overlaping it and show the apropiate Interface.
The problem is that I need to change the color/material of the floor, and I can´t use the volume collision, because the player is always walking on the floor. So what I want is that the change color floor Interface appears when the player look at the floor in a very straight angle.

Please, look at this video, to watch the exact moment when the player looks down to show the menu, check 1:47

Can anybody help me?

Thank you so much!

This could work, using a trace.
I done the below in a pawn blueprint.
The ToTrace variable is a static mesh, that is editable, if you have the pawn (or whichever bluepritn is doing the trace) placed in the scene, you can set that variable to be whatever you want to trace for.

It uses a dot product to know if you are looking nearly straight at it (a value of 1 is perpendicular, so .9 is nearly). If that is between .9 and 1, and the user is looking at the specific mesh, the print screen will fire.

Even if you don’t do it that same way, a line trace is probably useful for it.

Thank for this code.
I am working hard with this, but don´t get any good results. I have some questins to good understand how it works:

  1. May I use the floor object to put in this Blueprint? I made a Class with the floor and put there the nodes, but doesn’t work. I changed Get Player Pawn for Get Player controller, but doesn’t work neither.

  2. If the best way to do it is using a Pawn Blueprint, it should be in the scene? what event should start the nodes?

  3. Trying with the floor Class I don´t know how to do a constant check. I guess it is necessary to check the tracing constantly during the game play, how to do that?

As you see I am pretty lost. Can you explain the whole process more in depth, please?

Thank you so much!

You could have it in a floor blueprint, that would work better actually probably. It would look like this:

That’s an actor blueprint with just a static mesh component, which is your floor. A tick event would have the effect of constantly checking, or you could call it on left mouse click for example. Then it will trace once per click. But if you want a glow effect when looking at the floor, it would need a tick event.

The true output on that branch is if the player is looking at the mesh, and is looking near-perpendicularly to it.

The *300 on the camera manager is the range of the trace. You may need to change these depending on the height of your pawn, or offset the start point of the trace. I just tested with a spectator pawn.

Make sure to uncheck “ignore self” on the trace

Yeeeees!! It works!!

Thank you so much man! you really help me!. Today I will go home with a smile in the face :slight_smile:

Thank you! :wink: