Linetraced bullet not moving to trace location


I have a problem at the moment where I want people in my game to shoot projectiles through linetrace. The linetrace works and it hits targets perfectly.

But the projectile it shoots can’t target the player when you’re on a elevated position like in this gif:

I’ve attached a picture of the linetrace from the enemies and then also the graph of the bullet that spawns.

The current way I am trying to do it is by spawning an actor at the end of the enemies gun that have it move forward only, do you guys know if there’s a simple equation that could help it move along a Z & Y axis as well or move towards a specific vector value?

Spawn bullet:
Bullet movement:

For instance I set up a destination vector value from the end line trace is there a way I can angle the movement towards it somehow?

Any help and suggestions are much appreciated!

I’m not expert but there are some projectile related functions in character class so you can look at them for check. Projectile movement component also is a way to go.

Thanks for your answer! I sadly encounter other problems by using the projectile movement as the only way I know how to get it to turn to the player is by setting the player(target) as a homing target which makes the bullet not have a fluent movement to it but angles itself mid-air after being shot and stuff which is not how I want my straight line bullets to work, thanks though!

What you should do is take the “hit location” minus “spawn location” which creates a vector that points from the current spawn location of the bullet TO the hit location. Then normalize this vector to make it unit length of 1 instead of whatever arbitrary length it would have been based off the distance to hit location. Once you have a normalized vector multiply it by the speed you want the bullet to travel. Add that to the current world location of the bullet and it will travel in a straight line towards the hit location.

Thanks for your answer! This screenshot is what I got going right now from your answer, but it is still not going towards the target.

Can you tell somewhere where I might’ve misunderstood you?

Thanks for the help! I got it to work now through your solution! :slight_smile:

  1. You don’t plug that value into the spawn transform, that will just create a static “world location” value to spawn the bullet at. You need to plug that into some type of movement component, which brings me to the second point
  2. You need a “movement” node/component/logic. You can do this simply by adding a projectile movement component to your bullet actor, give it a starting speed in the right side details panel of the projectile movement component and you should be good. Once it is spawned it should travel in the direction you are aiming.

Before you spawn the actor what you need to do is line trace to a target, then you can use the “find look at rotation” node to plug into the spawn transform of your bullet. This will rotate the bullet properly to face the direction of your line trace out hit.