I currently have a projectile. It is using the UProjectMovementComponent. I want to have it be affected by a wind-value. My wind will just be a direction and a number indicating how much it is “blowing”. I would like my projectile to be affected by the wind direction and force.
Can i extend the UProjectMovementComponent to do this or am i better of creating my own custom movement component (which would mean creating the other physics-reactions again)? Any pointers in the correct direction?
Extend the Projectile Movement Component and modify the velocity each frame, that’s the best way. I do this for seeking missiles, and in reality it’s not much different.
There’s also no reason you shouldn’t be able to find a wind actor in the level and figure out the current strength / speed of the wind to modify the velocity as you please. Just make sure you cache it somewhere for easy access, you don’t want every projectile in the scene to be iterating over all actors trying to find one wind actor every frame.
If you’re doing Multiplayer, I would find a way to sync the wind actors seed / randomisation between server and client and have each perform the calculation, otherwise you risk clients becoming massively out of sync and relying on FRepMovement to update the velocity/position, and you’ll probably get large jumps / snaps client-side.
Placed a wind-actor in the world and referenced it from the gamemode. I then set the wind to the projectile when spawning it from my pawn and affect the velocity of my subclassed movementcomponent. Works good, thanks for quick reply