Download

Complicated Rotating Projectile Question

I have a spinning sword that I want to rotate in the direction of the swing. Right now I’m spawning it with a velocity of X and a rotating movement around Z axis, and setting the actor rotation based on the camera’s forward vector. This gives me a sword that spins horizontally traveling toward whatever you’re looking at. Great.

Now I want to rotate around the local X axis based on the direction of the swing, which is dynamic so I can’t preset this rotation. If the player is swinging from 10:00 to 4:00 when the throw button is released I want that 20-30 degree rotation to make its way onto the sword.

Any ideas?

I figured it out. I added two scene components to the tip of the blade and I set the second one to the world location that the first one was in LAST frame. Then I found the look at rotation of their relative locations (ignoring the axis that is the length of the blade - Z in my case) and set the relative rotation of the capsule component they were on to the result. I then fed the World rotation of the capsule into the thrown weapons actor rotation after spawning it.
Without going through this, the spin would be rotating in odd directions if the weapon wasn’t facing the same direction it was swinging.