Download

Affect projectile with wind?

Hello!

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?

This guy: Wind Effect on Projectile - UE4 AnswerHub Apparently used forces to do stuff.
I don’t think that you can have such parameter set by a wind actor,so, either add forces or make your own projectile movement component (a lot harder), adding that extra force as a parameter.

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.

Thanks for quick replies!

Modifying the velocity of the projectilemovementcomponent seems like an easy way to do it. Will try as soon as i get home and report back on my success or failure :slight_smile:

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 :slight_smile: