Spawning actor on mouse position

I’m trying to spawn an actor at the mouse position, but it is spawning at a wrong position.

My blueprint is like this:

In the first image, you can see that my mouse cursor is at the circulated location but the spawned actor is to the left of that location. Does someone know how to fix it?

Youre doing your spawning using world position not relative position. You have to convert that using either getForwardVector and/or getLookRotation and adjust the spawn point accordingly.

Also, amy reason why you arent using “convert mouse position to world location”?

I’ve tried to do what you said, but I’m not getting the result that I want. Could you explain more what I need to do? I didn’t understand how I can convert the world position to relative position using the getForwardVector and getLookRotation.

I got it! Here is the blueprint:

I converted the mouse location to world space, divided the “Arm Length” of my “Spring Arm” component by the ‘X’ axis of the world direction and multiplied by the world direction. After that, I added the result to the world location, so I got a point in which the ‘X’ axis is the distance from my arm length. I’m not sure, but probably I could just multiply the Arm Length by the world direction and I would get the same result.