How do you make enemy projectiles move towards the player?

So basically I made an enemy that shoots projectiles at the player but atm he only shoots projectiles in the direction he is facing, this is good and all but if a player is above or below the enemy then the projectile wont aim at him.

So my question is does anyone know how to make a projectile move towards the players current position? So far iv only found tutorials on shooting projectiles from a gun the player wields but nothing on enemies throwing projectiles at the player.

Any help would be great, thanks in advance -unholypimpin

How are you getting the direction it’s facing? I find dealing with rotators incredibly frustrating and unintuitive

This makes my enemy shoot in the direction he is facing, but its just a straight line which doesnt work to well except on flat surfaces. For example if i’m on a platform and the enemy is below the platform he will shoot in my direction(which is where he will be facing) but wont take into account that I am above him so the projectile wont shoot up at my z height. Pretty much he can only hurt me if we are both on equal ground.

So I tried this and now the enemy shoots away from my character rather than at him.

Can anyone help me out here? I have yet to find any documentation on projectiles being aimed at targets. I thought something like this would be as simple as plugging in my characters location and preseto! my monster shoots at the player but no…

Can I suggest getting familiar and abusing the **** out of DrawDebugLine? I often find I have issues with rotation because rotators act a lot more complicatedly than vectors

Is that movement… a function? That takes a location and does what with it?

Also I’ve got a feeling ControlRotation isn’t what you’re looking for… If you print or debug the output you can see if it’s not supplying complete rotation. You may need to manually do that? I suspect you’ll find ControlRotation is only giving you one axis of rotiation

The first screenshot only pertains to the projectiles spawn location not its trajectory, The problem i’m having is the projectile is not aiming at the player at all.

You’ll need to debug the rotator you’re getting your aiming direction from, I think. Draw debug lines, Draw debug strings… Work out what isn’t changing

The secret sauce you’re looking for is Find Look at Rotation and Get Forward Vector

So will this fix my problem with the enemy aiming his projectile at a fixed height and allow him to aim at the player even if hes above or below him?

Idk if you have ever played classic shooters like doom but the effect i’m trying to reproduce is enemies that can toss projectiles at the players current position, that position isnt just the angle but also the pitch so the enemy could throw projectiles at the player who is running below him.

The problem with lookat direction is that you want to fire your projectile where you are aiming, and you want to be able to aim left+right+up+down is that correct? lookat would just fire it from you to the target regardless of the way you are facing.
And if I am correct, the problem you are having is that the left+right aiming aspect works but it’s as if you are always aiming at a flat level, never up nor down.

We need to know more about your targeting system, how you control up and down aiming, and you also need to debug that control rotator! Use a debug text or just print it to the console for ultra ease. I still suspect you’ll find the left+right rotation working but that it’s not supplying your up and down rotation. in which case you’ll need to take a step back and find out why it’s not doing that.

If in doubt… debug. debug! DEBUG! the built in tools are great

@rodstone this targeting is for the enemy not the player, I already have the characters guns working.

@Furroy I copied that code and the projectile that the monster throws at me doesn’t move at all now, what am I doing wrong?

The values needed for the impulse function need to be very high sometimes

So I tried something else to get my projectile to fire at the player but still didnt work, I used a trace from the enemy to the player and the trace would spit out of the players location and right after that it would set that location as the recently spawned projectiles velocity. My projectile still doesnt move at all, here is the code i’m using. Can anyone see anything wrong with it or show me how to fix it?

I’m really trying to get this to work, so any help would be really great! Hopefully someone from epic or another experienced BP programmer will see my post and point me in the right direction.

You’ll just have to keep increasing the velocity until it moves, don’t be shy! You can see from my example I had to multiply by 25000. You can also experiment toggling the Vel Change checkbox to see what works for you.

Finally after multiplying by 25000000 it moves but it still shoots away from the trace location, how can the trace be spot on but the projectile somehow wont go towards where the raytrace hit at all?

Using the blueprint nodes I gave you? Or from this new line trace?

New line trace, I guess I could retry yours again and go up to 2500000 multiplication

Are you doing debug lines yet?

yes iv been debugging everything and even printing out the debug cordinates.

@furroy Okay I tried your script again and copied it node for node and now the projectile shoots at a specific spot in the map and doesnt change. This spot isnt where the player starts either.