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
Sorry for the mess, this function is due for cleaning. it seems to work however up close this happens
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.
Any help on getting this to work would be great.
Lots of ways of coming at this one.
- 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.
hope that helps.
How would I use a detection volume, can you point me towards the documentation of that?
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:
This looks like it might do the trick, I will try it next chance I get. Thanks for the reply
I would like to compare if you don’t mind. my seems to be working but I am always looking to improve blueprints. Still getting the hang of them
No problem. Hope it helps. My tracking is handled through a separate function. l can post that as well, if you need it / just want to compare.
Great, thanks for the posts. you have been a big help
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…
Did you resolve this? It looks like the trace start is from the turret. I’d try placing a socket at the turrets pivot point and start the trace there.