Advertisement

Aiming in third person games where player is not centered in the middle of the screen

Started by February 22, 2022 02:31 AM
2 comments, last by JoeJ 2 years, 9 months ago

I have been thinking about how aiming is done in third person games where the player is not centered in the middle of the screen, especially with regards to bow and arrow mechanics. We would have to rotate the player along global y axis and rotate their torso and arms along global x axis to align the projectile with the target. I'm interested specifically in the y axis rotation. The issue is that reticle is defined in screen space and we need to transform it into world space. To do this we need to define what the z coordinate is and we can't get that information from the reticle. I guess one way to get the third dimension would be to cast a ray from center of the camera towards the reticle and check for the closest collision. However one issue I'm having with this is what if player wants to aim higher than the target. For instance slightly higher than the enemy head, since the projectile's y coordinate will get decreased with distance. In this scenario the ray doesn't collide with anything and we are not shooting where we want to shoot. Does anyone know of any potential solutions to this?

I just watched some gameplay from games like Tomb Raider and Horizon Zero Dawn, which had some good feeling bow and arrow mechanics, and it seems like they are using a constant set z value and not define it based on camera ray intersection? What do you guys think?

I used to play alot of chivalry : medieval warfare and the archer had a 1st and 3rd person player controller. The way I understand it is that when you are aiming at something, you cast a ray from the reticle into the scene and you get back a value, t, for the intersection where rayIntersectPosition = cameraPosition + cameraForward * t. You then know to shoot the arrow in the direction of normalize(rayIntersectPosition - playerPosition) where playerPosition is offset from the cameras position. But when you aren't aiming at something, it would just use a constant value for t, tuned to whatever seems reasonable, but usually something like 20.0 so it crossed the reticle some place far off in the distance. All this aside, it was well known to switch to first person when shooting the arrow and change back to third person when using a knife/sword etc… because of how badly the third person aiming was balanced.

Advertisement

orange1 said:
I guess one way to get the third dimension would be to cast a ray from center of the camera towards the reticle and check for the closest collision. However one issue I'm having with this is what if player wants to aim higher than the target. For instance slightly higher than the enemy head, since the projectile's y coordinate will get decreased with distance. In this scenario the ray doesn't collide with anything and we are not shooting where we want to shoot. Does anyone know of any potential solutions to this?

I would say, the over the shoulder TP camera is not meant for precision in the first place. It's already hard to walk a straight line towards your goal, rotating the view also is an awkward experience. So it's a compromised solution.

Thus, the appropriate solution to me clearly is assisting the player. Meaning, the player can aim the crosshair exactly over the target like in FPS, so your ray tracing proposal just works.
The computer should then calculate the parabolic trajectory and launch angle to hit the target automatically, not burdening the player with such details he could hardly predict and control.

One related issue i often think about is: What if the crosshair aims to the goal unblocked, but the trajectory from the weapon to that same goal is blocked by an obstacle, like a rock?
Should we allow the projectile to travel through the obstacle to hit regardless, to reward the players proper and precise aim? And, would doing this allow to exploit / cheat, which we do not want?
Games seem to handle this differently across titles, sometimes even differently for various weapons in the same game. Surely there exists no single best solution. The compromise made from choosing TP further infects the system :/

On the long run i wish we could get rid of crosshairs all together, maybe by making protagonists smarter and more automated. But if we go there, we need to compensate the loss of gameplay with some other challenge beside shooting, and it's hard to come up with something.

This topic is closed to new replies.

Advertisement