3D Cursor/CrossHair

Hello . I want to make, for a project, a cursor and a crosshair that would react with the environment.

Like in this video

I started to think in some logic using a linetrace. But I can’t get the desired effect.

I am posting two links that show the main functions.

My Logic : Set Targetbased on Mouse Position posted by Peppone | blueprintUE | PasteBin For Unreal Engine

FireStart is an Arrow where the projectile Start .
Fire Target is a collision sphere in Default SceneRoot at 4000 unit far on X axe .
image

If someone have a better logic or find what doesn’t work on mine i’ll be glad :slight_smile:

Ps : it’s important for me to keep the delay whitin the cursor and the crosshair when it moves .

Hey @PepponeTV

you could do it like this:

  1. Get the location where your mouse is pointing:

  2. Get the location where the gun is pointing:
    image

  3. Show a billboard where your gun is pointing:

  4. Use the mouse location to rotate turret and gun with an interp:

The pawn blueprint:

The pawn components list:
image

UE5.1 | 3DCursor.zip (98.2 KB)

Thanks a lot @L1z4rD89 for the proposed solution. Even if I couldn’t apply it identically, it helped me a lot to find the logic and adapt it to my situation. I just have one small problem to solve now…

My game is in 3D and the obstacles come from the front. When the 3d crosshair passes from a very close obstacle to a more distant obstacle, theres is an issue that makes the interpolation buggy, which takes much longer to reach the cursor than usual because the 3dcrosshair is far away . I tried to increase the interp speed of the X value and it’s better, but the Y and Z location are always buggy .

Part 1/2 : Get the location under mouse cursor and Save in Target Location Variable . If there is nothing under the mouse save the location of the LineTrace End .

Part 2/2 : Interp between last 3D cursor location and the new cursor location

Hi there @PepponeTV and happy holidays!

This topic has been moved from International to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space. Hopefully, this category change will help you (or other devs!) to get an answer.

In the meantime, good luck and happy developing! :slight_smile:

2 Likes

Hey @PepponeTV
here is another method:

3DCursor.zip (7.0 MB)

Thanks !! It’s perfect ! <3