Projectile spawns next to the player

Hi everyone,

I’m developing a top-down game in Unreal Engine 5.4 and ran into a problem with spawning projectiles using the Gameplay Ability System (GAS).

When I press a key, a gameplay ability is activated that spawns a projectile from the barrel socket of the character’s weapon (using a socket on the skeletal mesh). However, when the character is moving, the projectile appears to spawn noticeably behind or offset from the character’s position.

As shown in the attached video, the first projectile is spawned locally on the client, and the second (delayed) one is spawned by the server. The issue is especially noticeable with the server-spawned projectile—it visibly appears to the side or behind the character, making the whole effect look awkward and unsatisfying.

I suspect this might be due to the character moving quickly while the projectile is relatively slow, so the spawn position lags visually. But I’m not sure if that’s the core issue or if something else is going wrong.

My questions are:

  • Is this offset behavior expected due to the difference in movement speed between the character and the projectile?
  • Is there a good way to correct this (visually or mechanically) without simply increasing the projectile speed or reducing the player speed?
  • Would you consider this a real problem, or is it negligible and I’m overthinking it?
  • Do you have any best practices or suggestions to make this look more polished?

I’d really appreciate any insight or tips. Thanks in advance!

Video showing the issue:

Hey @MyKarcio!

I’m just going to go ahead and answer your direct questions. :slight_smile:

Yup! These would be classified as slow-moving, or at the very least slow-accelerating. Typically this would be fixed by increasing the projectile acceleration or shortening the spawn’s load time.

See above, but personally what I would do is maybe try directly after spawning have the server teleport the projectile to the transform of the rifle muzzle, so once all the hard work is done all it has to do is set a new location. This could be done on both client and server with hopefully a similar output. Another idea is object pooling.

Disclaimer: This link is not associated with Epic Games, Unreal Engine, or their partners.

It depends on how the game plays, really. Hotline Miami? :frowning: Throw the whole game away. Heroes of Hammerwatch? I can work with that! :slight_smile:

See #2 :slight_smile:

Hope this helps!

2 Likes

Heya @MyKarcio! Just checking on you to see how it went. What did you end up going with? I know object pooling is a little more complicated but it’s SO good when it’s fully set up!

Let us know for future answer seekers what you did! :slight_smile:

1 Like

@Mind-Brain First of all, I wanted to thank you very much for your answer!!! I discovered why the server projectile appeared a few frames behind the client projectile. Instead of sending to the server information about the player’s position and direction, I used the data on the server, which was often slightly behind due to lag simulation. For now, I’m focusing on improving this, in the next step I will add object pooling and test how linear interpolation of the client projectile to the server projectile looks like. (Sorry for replying so late, but at work I’m dealing with migrating the entire architecture to Kubernetes and to tell you the truth, it’s sometimes hard to start programming after work :stuck_out_tongue: ). I’ll get back to you at later stages, to make a bigger thread for beginners here, if they have similar problems as me!

1 Like

Btw, @Mind-Brain you do a very good job helping others and thank you very much for your contribution to the community :heart::heart:

That’s really kind of you to say. Thank you so much! I try my best!

I really appreciate that. :slight_smile:

1 Like

After fix in spawning projectile I added interpolation. Looks like good starting point for sth more :smile:

1 Like