+1 vote

background: in my third person shooter i have a ray cast that comes from the camera and serves as the direction that a projectile should travel to. A projectile is instanced at the end of a gun and I use the look_at function to get the projectile to face the direction of the collision point of the ray cast.

the problem is that because my camera is slightly above the player, quite often the projectiles fall short and hit the ground before hitting their targets. I know why this happens and it's because of the look_at function, this function is making my projectiles look towards the ground too sharply. Overall, this system is great for a first person shooter but not so good for a third person shooter where the camera is offset or above the player, which means to look in front of myself In the game, I have to look down slightly which causes this problem. Moving the ray cast higher or lower means that the ray-cast no longer accurately points towards the cross hairs at the center of the screen.

in Engine by (58 points)

I don't see why the look_at() function is the problem, its just making the bullet point at the raycast. The raycast position is the problem isn't it? +1, by the way, because I really want to know how to handle 3rd person shooting.

I tinkered with it some bit, and got rid of the ray cast offset and had it be in the direct center of the camera and in front of the player slightly. I used to have this. It works better now. I cannot complain, it does indeed work

My question about raycasts has always been: Doesn't It look like the bullet is going the wrong direction? I get that in third person, the camera is never lined up with the player and thus the bullet must be going a different direction than the gun is really pointing, but how do you make it look natural?

do you mean make the player mesh rotate with the direction of the ray cast? in my game the player rotates towards the the direction of the raycast( or camera) when the fire button is pressed, so that it looks natural.

thats a good way to do it, but I noticed that in a lot of third person or first person games, if you look closely the gun model is not pointed where the bullet is going. It's close, but usually angled to the left or right. I believe that this is to make it so you can see more of the gun, but I have no idea how you achieve a balance. This is a complex topic and I really should ask a question here sometime about it. :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.