Having a issue with my blueprints. Have turrets that rotate to face their target, however I don’t want them to shoot unless they can see their targets. So I made a blueprint that does a single line trace and returns true or false if it hits the intended target. However the lines seem to be less accurate the closer the target is to the turret
the turrets up higher are pointing directly at the turret on the ground. I know this because if I force them to fire they hit the turret dead on. However because the lines are going off in the wrong direction they never get the call to fire.
there is more than one type of trace node, some do boxes, and area based tracing
also you probably can get away without even using a trace using a detection volume
you could use impact point instead of location, impact is supposedly more accurate,
trace complex tickbox may help too
you could cheat this by adding a detection volume around the turret at about where it has trouble finding the target. assume if something is that close, it can see it.
Here’s the setup I’m using. Originally the LoS function was in the turret BP, but I moved it out to my personal library. Now the function in the turret BP is just a call to the library function:
Yeah I have made that mistake before. What I end up doing most of the time is just making a sphere component or something like that and making the mesh a child of it. then I can do all my rotation other functions on the sphere component and the mesh will follow.
Here you go. My turret is two pieces. The base and the barrel, with each turning separately. I did it that way so the base could rotate with yaw, and the barrel could rotate with yaw and pitch. It also gives me the opportunity to hide the barrel section when I destroy the turret, leaving the base behind with some spawned effects. It’s just a little test/learning map for me, so I’ll be posting it in the forums when I’ve gone as far as I intend to with it. Anyway, here’re the pics:
Note, on the MakeRot node for the base, you can ignore the 180 rotation for the roll value. When I imported the mesh from blender the settings were wrong and it came in upside down. I was lazy, and rather than reimporting, I rotate it to the right position, and use this to ensure it stays right side up while turning. I’ll fix it at some point…