- Home /
Best way of rendering a Sword Slash or other Weapon effects?
In many games that have weapons, when they are swung, it has a motion trail/slash coming off of it. I was curious to see if anyone has seen this being done in Unity3D, and if so, how?
I was wondering, is this something done when creating the model/animation of the character or is it a particle effect/ instanced object? Does anyone have an example or a link that will assist me in doing this?
Thanks!
Answer by jonas-echterhoff · Nov 03, 2010 at 01:48 PM
We implemented something like this in FusionFall. Basically the sword animations would have animation events to turn on or off the trail effects. The sword mesh would contain two transforms which defines the position of the trail, and then a script running each frame would use those two positions to set up a custom mesh for the sword effect.
Cool. I was thinking of using a trail renderer or this: http://www.unifycommunity.com/wiki/index.php?title=Trail_Arc_Renderer
The custom mesh, is it generated by a script, or is it a pre-existing mesh that is activated once the attacker swings his sword. And as far as interpolating the slash effect, is that texture based?
I wish there was an example.
1) Define two virtual points in the local of the sword where the slash effect will start and end
2) Define animation events to start and end slash effect
3) By using the two points (p1,p2), on each update function, add a polygon (vertice points of the polygon are: p1, p2, previous_p1, previous_p2) to a runtime-created-mesh with slash texture applied
Answer by StephanK · Nov 03, 2010 at 08:34 AM
I don't have an example for you, but I'd try to achieve this with a particle system, that gets instantiated when the animation starts and destroyed once it stops. If you have a 2D game using sprites you would put this into the spritesheet animation. If you have pro this could probably be done as a kind of ImageEffect.
Answer by gizmosan · Jul 02, 2012 at 10:46 PM
This is concidered kinda hacking from a development stand point :) but I was able to make a dummy GameObject and place a Trail Renderer to it. Then when the character swings its sword the trail renderer shows a trail. Sadly, I was unable to stop the trail from spawning. Maybe you can do that in script. But it looked pretty convincing!