Development Blog‎ > ‎

Wind sword level three effect

posted Jan 5, 2012, 2:32 PM by Mavrik Games
I've been working on the level three effect for the wind Astra sword for several days. I wanted to make a tornado spawn and fling the enemies around. The first thing I did was to set each enemy in the radius of the tornado to ragdoll mode. I then started applying forces to try to make them orbit around the center and lift up into the air. It was a bit of math and I had to bust out some physics to calculate the radial force based on the tangential velocity. In the end, I got something working, but it didn't act like I wanted it to. Then I discovered that the UDK has a set of classes called NxForceFields that basically provide physics forces on rigid bodies. They even have one called NxForceFieldTornado, so I decided to give their's a try.

For a class so perfectly named for what I wanted it to do, it was a giant pain to get it to work like I wanted. First of all, the bNoDelete and bStatic constants are set to true, so you're not allowed to spawn one at runtime. So I wrote a subclass just so I could assign these to true in the DefaultProperties. As long as I had to have a new class, I wrote in a couple of functions to activate and deactivate the tornado. Next, I found out that for some reason, you have to specify a ForceFieldShape for the NxForceFieldTornado, and if you don't, you don't get any forces. Call me stupid, but I think a tornado should be cylindrical with the bottom radius smaller than the top, so shouldn't this be the default? I mean yeah, let me override it if I want, but if you're gonna call it a tornado, make it act like a tornado!

Well I went searching for a ForceFieldShapeCylinder only to find that there isn't one. I could do a box, a capsule or a sphere, so I went with the sphere. Now I finally saw some forces acting on my ragdolled enemies, but lo and behold, they weren't being lifted up but instead being pushed to the side. I found out that by default the ForceFieldShapes point horizontally instead of vertically, so I had to rotate my sphere -90 degrees. So now I thought it should just be a matter of setting the strengths of the forces. Little did I know that this would be an enormous headache. It seems that the radial force somehow affects the rotational force, because if I increased that, my enemies spun around me faster. Too little, and they went spiraling outward very slowly.

Finally, after literally hours of experimenting, I got some results I was satisfied with. One thing I still don't understand though is the BSpecialRadialForceMode boolean. All I know is that by setting it to true, it seemed to stabilize things a bit, but I have no idea why. I still don't know if mass is taken into effect, so I have no idea if enemies with different masses will behave differently in this tornado. I think I'm done tweaking it though. If I run into issues later, I may just get rid of the radial force altogether and apply a separate calculated force to each enemy individually. I gotta say, I'm a little disappointed with the NxForceFieldTornado class. Without a serious amount of tweaking and customizing, it doesn't even act like a tornado.
Comments