Below I have attached the blueprint for the line trace that I use for all of my projects. As you can see, I have used the forward vector from the flashlight that I have attached to my character, however, I believe that you could simply use the forward vector from your character if you do not have something like this attached. I have circled the value that I use to control the length of the line trace. At 2000, as you see here, my line trace is very long. For some projects I have had to reduce it down to around 200, simply to get a much shorter line. If you need the line trace to verify that you are looking at your AI, simply use a “Get Class” node off of the “Hit Actor” output on the break hit result. I have attached a screenshot of this setup as well. Hope this helps!
I have a crossair in the middle of the screen that shows where the Player is aiming.
I want to show a message if he is aiming at a friendly target and if that target is within a certain range.
The code above get the jobs done but it is not working.
All I know if I multiply a big number to the forward vector I get an accurate point till a certain range, but it isn’t what I am looking for.
I want that number to be the length of the ray that start from the player and goes to the point where the player is aiming.
According to what I understand GetForwardVector is a vector, therefore if I just multiply it by a scalar I should have the same Vector, pointing in the same direction but just longer.
What I’m doing wrong?
The above graph is correct. If you want to double check it turn on the draw debug type so you can see the ray you’re firing.
That being said, once you start working with big numbers things become wonky. Namely, since vectors are made out of floats, that means they are limited by the same precision issues as floats. Anything past ~100k (Rough estimate) is probably not going to work as your vector will start deviating.
I did activate the draw debug line and I get the same strange thing,
with small number (like 1000) I get a line that is not going where I’m aiming,
with huge number (1000000) it is accurate.
That means that your actor’s eye position and rotation aren’t correct. Try adjusting those.
This is the Character that I have, which one is the actor with eye position/rotation?
Characters have a property in the default panel called “Eye Height”. This determines how high above their pivot point the eyes are located. The way the rotation is returned is a bit iffy though - it will always return the controller’s control rotation. So if you don’t use the control rotation to look at stuff then the eye rotation won’t be of much use to you.
Thanks it seems that it works by adding a new arrow object, I don’t quite get why it works only if attached to Mesh2P (which is just the arms with a weapon copied from the shooter sample) and not on Mesh3P (the entire mannequin). and I still don’t understand why GetEyesViewPoint doesn’t work but for the moment you’ve been a great help and I will use your solution.
Thank you very much
Sorry but I don’t quite understand the control rotation part,
I copied the first person template and I’m trying to work with it.
I look around using the mouse.
Glad I could help!