How do I account for player motion when firing a projectile?

My project relies on the player standing on a moving platform, the platform is moving at approximately 60km/h (distance of 100,000 units or 1km every minute). The project is an FPS so shooting is a key mechanic: using any weapons that require a projectile motion results in a high velocity firing backwards along the platform’s path and very slow (if not slower than the platform) when firing forwards along the path. I want a consistent initial velocity, such that firing either forwards or backwards along the path has the same apparent speed for the projectile.

Basically I’m looking to add the velocity of the player to the initial velocity of the projectile, however the intuitive method of getting the player pawn’s velocity and simply adding it to the projectile’s velocity on either construct or begin play yields no good improvement.

The problem is one of timing. To solve this, create a vector variable in the projectile called “InheritedVelocity”. In the details panel, set it to “Public” and “Expose on spawn”. Now go to where you spawn the projectiles and you will see the inherited velocity pin. Plug the pawn velocity in there. Then in your projectile, when you set the initial velocity, add in the inherited velocity. It should work fine (I’ve done it before).

Oh and BeginPlay is the right spot to set the initial velocity.

This still isn’t working, and I’ve figured out why: the motion of the platform is on a timeline linked to a spline, the event graph sets the world transform on the update node of the timeline. The players motion is inherent from the teleporting (every frame I suppose) of the platform, as upon printing the player’s or the platform’s velocity, it shows 0,0,0 (unless the player moves using input).
Your solution seems logical and I see no reason why it won’t work if the platform actually moves so I’ll mark it as the answer.
I’ll see if I can rework the platform motion to suit this answer :slight_smile:

For anyone looking at this answer, it isn’t compatible with teleportation based motion such as “SetWorldTransform” on things that are comparable to a Tick, a workaround is below

I worked around this (without altering my spline/timeline pathing) by getting the forward vector of the platform’s current rotation, multiplying it by the platform’s speed (in units per second) and using that as the Inherited Velocity, the rest is thanks to you.
In my example picture below my platform’s speed is determined by a float handle tied to the Timeline where 1.0 is equal to that 100,000 units every minute, hence the multiplication of the “Train Speed” prior to multiplying by the ForwardVector by a factor of 1667.

Ah I see. The pawn velocity is internal and doesn’t consider things like standing on moving platforms. GJ!

For platforms that aren’t always going the same speed you can do something else. On tick (in a platform BP), subtract the current location from the previous location and divide by the tick’s delta seconds.

I meant subtract the previous from the current.

I thought ahead on that one, the platform’s actual motion along the spline is also inherited from the variable “Train Speed”, as that determines the play-rate of the Timeline on every update, so if the play rate is altered, the next time the timeline updates, so will the play-rate.