My game don't show a good hit location

In my game bad showing hit location. When I aim at the sky should show zero, and do not do it. I tried the friend code Unreal provides a much simpler way to accomplish all of this, but the console says I’m aiming for myself.
My code is here https://github.com/Tajgi/04_BattleTank_Udemy
Please help me.

Can you share a screenshot of the game with the red debug line? Can you also tell me what collision channel the player tank BP is set to?

My red debug line is here https://youtu.be/Y8bwpIdgRXU. Where can I find collision channel for player tank BP?

Lets check StartLocation variable and everything related to it.
If this don’t solve your problem, lets check your Tank’s Camera position too.
I hope this helps.
Good luck!
Sorry about my bad English.

I don’t know what you mean.
auto StartLocation = PlayerCameraManager->GetCameraLocation();
This is my StartLocation variable and this is engine’s functions, not mine. So what I have check in this?
I had a problem with camera position and then I copied the code from Ben’s GitHub.

Maybe the problem not come from your codes, have you checked your Tank blueprint ? Transform of each SceneComponent, Physics in Tank Static Mesh component, etc… Hope you can find out the solution for your problem soon. I don’t have much experient so I only have a few tips for you, I’m sorry !

hi Tajgi,

Did you find the solution to this?I am also getting weird hit location coordinates even after trying Ryan’s solution too.

Hi,

Actually I somehow fixed the issue. I am not sure what exactly happened. I was refactoring some code and it started working. What I suspect and recommend you to check (which was most likely the case for me) is there is some code path that is getting executed where the hitLocation is not assigned any value so it takes on garbage values. If you try logging hitLocation on each path (inside the if (GetHitResultAtScreenPosition(…)) block when the hit is a success and in the else block when the hit is a failure, it needs to be set to 0). Then it started working for me.

Privacy & Terms