Simple Blueprint firing turret

hey all.
Im trying to make a basic turret. attached is a sphere collider that when entered, the turret will fire out projectiles directly towards the intruder. now i tried to modify a “fire projectile to mouse location” blueprint using the intruding actors location rather than the mouse however this failed.
Does anyone have any help on this, or the best way to achieve it?
Thankyou

Please what?

Could you post screenshots of your Blueprints?
I don’t understand what you want to do. Do you have
a basic turret by now and you just try to modify it or
are you still trying to get the turret to work?

For what do you need the “fire projectile to mouse location”
blueprint?

A turret that shoots at the player or intruders could just use
the Collider and set the “Other Actor” to the target the tower
should aim at. Than you can have a function for the tower
to shoot. Since he is already looking at the actor by some
function that lets the turret aim at the player, he should now
just shoot. :confused:

Please some more information. :smiley:

Sure, my bad
so right now i have a turret object, attached is a sphere collider which acts as the radius the turret will fire. when an actor goes into the radius, i want the turret to fire.

during runtime when i or a Ai character walks into the radius

as you can see it says its spawning the projectile, however nothing is happening on the screen :confused:

Ok update… i managed to get the turret to fire towards the player, but only when the player crosses the collision into the surrounding radius sphere. Is there a way to constantly find the players location on each shot fired?

Ehm, the tower is only firing when you enter the Radius? :open_mouth:
Have you watched at your BP at Runtime, checking if something closes the gate?

Normaly you should open the gate when he enters and close it when he leaves.
You can also change your setup to something with a bool.
Let the Tick check a bool with a branch. Lets say “bSomethingInRange”.
Change the bool to true if someone begins the overlap and set it to false if he stop overlapping.

It fires non stop fine when I’m in the radius. The issue is it fire towards the point where I entered.
Looking from above, let’s say my player enters the radius at the top. The turret fires towards the top but keeps firing towards the top… Even if I move round the turret to the bottom, it still fires towards that top point where I entered.
What I’m after is the turret to update the location of the target before every shot fired. Hope that makes sense lol

Ah ok, that’s because you used the Position to calculate the aiming point only at the Overlap point. Try saving the player inside a variable or better inside a list when he begins the overlap and delete clear the list or the variable if he leaves.
Than use the list/variable and get its location. This should always get the current location of the actor and not only the position when he entered.

The thing with the list is: If multiple enemies enter the radius, the turret will only attack the last one i guess.

So you make a list for him and add an actor each time someone enters the radius.

If someone leaves, you search the array(list) for that actor and delete it.

You just need to think about what array element he should attack. I guess you could just take the index 0 of that array, so the first player who entered and than get his location until he leaves. Could be that you need to resize the array each time or the delete item puts something else on index 0 if the actor which left was at index 0. I don’t know that right now, so just test it.

I also wouldnt use a gate but a branch. The condition would be that the array is not empty. If its not empty, there is an enemy in range and he should go through the array (or take index 0) and attack that enemy.

I guess this would be the best solution.

Hi ,

This is something that I had been working on in my free time. What I have is when the player overlaps the radius (in my case a cone), it draws the distance between an arrow component in front of the turret and the player. So every second it is checking to see where the player is and fires there, instead of just firing at the initial cross location.

Thankyou for your help :slight_smile:
ive got rid of the gate and used a branch like you said, also tried to do an array however its still not working :S now its back to not firing.
well its firing the projectiles somewhere as the object count rises quickly when i enter the area. but i cant see a single bullet. this is what im using now

This works! Thankyou!
so it turns out there are two types of overlap event node, by using the same as you it worked fine! one issue i still have is that the bullets are being counted as actors, so when they leave the radius they close the gate regardless if the player is still inside. Ive tried adding tags to the player and using those but no luck

Thanks for this, I always find it so difficult starting an Actor/BP but I find it much easier to extend off it.

I have a great turret setup now nice and simple and it aims well too!!

Hi here is a good tutorial www.vaduunlabs.com/index.php/en/tutorials/29-adv-turret-animation.

With the help of this tutorial, you will be able to animate turrets in UE4, which are always tracking the target correctly, regardless of their own orientation.