Vector Math Help

Hey!

I’m hoping someone can help me with this, probably stupidly easy problem.

I’ve provided the image of the section of blueprint that I need to resolve.

Basically, it works really well when mouse the cursor up, but any other direction and it doesn’t work correctly, or the angles are off etc.

To confirm, the Crosshair Vector is taken from get hit result under cursor by channel, hit location. Maybe something to do with this vs me using Relative Location on the boom? I’ve been reading about Normalize and Vectors, but tbh it’s still all going over my head.

Anyway, looking forward to a reply!

Cheers.

Could you explain what you are trying to accomplish? It looks like you’re trying to make the camera follow the cursor within a certain distance from the player, but it’s hard to tell just from your code.

Thanks for replying!

Sorry, should have explained that. Basically your correct, its a top down character that is centre of screen. The mouse/crosshair defines the characters direction.

I’m trying to achieve that when the mouse moves far enough away from the character, the boom that the camera is attached to moves roughly between the character and the crosshair. This is to give the character the abiltity to look further out than a standard top down view.

I had a clamp to stop it from going too far out.

Currently, it works perfectly if the mouse is moved up the screen from the character, but any other direction and the camera moves in the wrong direction.

Should also mention the camera has the ability to be rotated around the character as well, so I thought somehow I should be getting forward vector from the camera too?

Again, any help would be much appreciated. This bit is completely confusing me :frowning:

Cheers,

It’s kind of hard to say without seeing how it’s behaving, but to start, I’d replace the Find Look At Rotation and Get Forward Vector node with a vector subtraction -> Normalize Vector node. With vector subtraction, you would subtract the target position (crosshair) by the player position. That subtraction can then be plugged into the Get Vector Length node and the other subtraction node can be deleted.

I have a feeling I did try that, as I found a post with a similar Idea. Im not able to get to my computer till tomorrow night, so will report back after trying again.

Well I tested it again the way you outlined and it did not work.

I have got it to work correctly by changing the Look At -> Get Forward Vector nodes, to Get Forward Vector just from the Player Camera. Now it works correctly when moving the mouse around the screen, as in it extends the view correctly between the character and the Crosshair by moving the Camera Boom. But I have the issue in that when the camera is rotated, it extends in the original direction, rather than changing to the new facing.

1 step closer, but still no cigar. :stuck_out_tongue:

I don’t understand how your setup is. You should take a screenshot. :slight_smile:

be51fca4ee7272877f88f823393f825d56e92d42.jpeg

This works perfectly, until the camera has been rotated.

But, as in Second picture, when the camera has been rotated and the mouse is moved (the thinner fantastically drawn arrows are the mouse and mouse movement) the camera goes in the wrong direction.

To clarify, the top 2 screenshots are before and after with the correct camera rotation. Whereas bottom two are after the camera has been rotated.

Any Ideas?

When I get time, I’ll have to recreate it and try it out, but I’m thinking it’s because of the ‘Set Relative Location’ node. The positioning is being done relative instead of absolute.

Thank you for the help man!

I also tried using tranforms but it didn’t work very well. Though I still am learning most of this stuff.

The best I was able to get was roatate vector on axis, using the relative z axis of the boom into the angle node. It works correctly at standard view, and if I rotate to the right everything works in opposite! Haha. I couldnt figure out if that helps come to an outcome.

Was trying to figure out the angle, but everything I’ve read points to it only providing up to 180 degrees?

I have solved it by using Inverse Transform Direction node using the Camera Boom and Get Relative Transform These are connected before going into the Vector Lerp. I was trying to invert the location previously and then just realised what I was doing wrong haha.