Raycast for the third person

Hello, guys.
Help me please,
how to make a raycast for the third person.
The problem is in defining the camera position.
In first person I know how to do it, but in third I can`t define.

You want a raycast from the Camera to the Crosshairpoint?

This should be done the same way as in the First Person Template.

Get the Camera Position for the Start and add the Forward Vector of the Camera multiplied by the distance of the RayCast to it for the end.

Would you mind showing me your setup so i can tell what you may do wrong? (:

ok, thanks, I figured out.
But now another problem, can you help,
how to make that my player rotate follow the mouse?

and one more question, how to make shooting to the crosshair locaion?
now it shooting just in the direction where the weapon look.

You may want to google this. This was answered a lot of times and i don’t have the time right now to explain it again.

What exactly do you mean? You Line Trace Should go from the Camera to the point its looking at. You can use the hitpoint of that Linetrace to shoot your weapon.

I also don’t know what weapon we are talking about. A real weapon without projectiles or one with slow projectiles (like the FP Template).

A real gun will just be a second line trace from the Gun Position to the Hitpoint of the first Line Trace.

I don`t find any completely answer. What I have now, but work bad.

What is working bad there? I guess you would only want to change the Yaw axis or? Try breaking the rotation and making one. Only use the Yaw of the rotation and set Pitch and Roll to 0.0.

The rest shoul work :X If not, please tell me what you are experiencing.

Wups, sorry, i accidentally delted your answer. Only wanted to delete the other comment.

Your picture was this:

And i said:

What is working bad here? Could you explain what your setup is doing and what you really want it to do?

Maybe you need to only set the Yaw of the Rotation. Try to break the rotation and also make a new rotation. Use the Yaw of the break rotation and set Pitch and Roll to 0.0.

Lets hold over for time shooting.
And end up with turning.
What I want : to turn player in mouse direction, when I turn mouse - the player should turn in his direction.
I found a little information at the forum, but no much.
Follow those information I have implented my BP:
(http://postimg.org/image/ql54bzr1l/)
But player turn not smoothly, and not always turn. Can you check this BP.

Ok, so you want permanent rotation towards your mouse. I will have a look at it. I will use the Top Down Template for it. Give me some minutes, i still have something else to do (:

Here, this seems to work perfectly. My camera is turned by 90° so it is straight above the character. And the character is truning to the hitpoint of my linetrace.

http://puu.sh/ehXFb/099726e501.png

ye, it work,
but one more troubble, I upload a video, look at it please.
First 30 seconds as you can see it work good, but in last 10, as you see,
when ray is not on the wall the player follow to mouse with lags.
How to fix it?

That’s not lagging, your line trace is not hitting anything, so you don’t get a point to rotate to. If you place a wall there instead of nothing, it will work again.

sorry for long reply, there was a problem with internet connection in my city.
But if I want player to move in the outdoors, how to fix it?

I guess we stop using Raycasts then. Because the trace will give you a point when it hits. Without something to hit, you only have the endpoint. So, thinking about it, you/we should realize, that we don’t need a line trace at all.

Just take the Mouse position and its direction multiplied by… let’s say 1000 and use this spot for our rotation calculation. This works everytime:

http://puu.sh/ekd4J/24a8ab20e9.png

Though it seems you are using some more logic in this, because my camera isn’t turning with it.

It seems that you missed Get player controller node, because it must connect to convert mouse and get control rot. If don`t do it - there an error.
Ok, it look more better, I think it might stop here.
But the next problem what should be solve is shooting straight to the crosshair.
What I have now, two version:

  1. projectile move from the camera (as I understand), and move where the camera and player look, not to the crosshair.

  1. And the second way I go, it`s look a little better, because projectile shoot from the gun_muzzle_socket. But not to the crosshair.

It seems ill go crazy today))) This is what i made, I know its crazy, and I need in help))

No i didn’t miss the PlayerController node, since my logic is placed inside the PlayerController. Thats because i can use “GetControlledPawn” for example.

If you want to shoot to the crosshair, you need to make a line trace from the cameraposition in camera direction. So get the forward vector of the camera and add it to the position (multiplied by the distance of course).