Swipe/slash attack

Hello, I have little experience with playcanvas so far.
Please, tell me how I can implement such a blow (swipe/slash) as in this old project.
I can’t figure out how I can do the same swipe/slash but to my texture.
Copying the code did not lead from the reference did not lead to the result…
Below I have attached an image that should be used in this action.

You are trying to make a character do a slashing animation, correct?

Hi @lolik and welcome,

Yes, that’s an old project, uses legacy scripts. Copying the code won’t really work in current projects.

If it makes it easier, and it’s easier with the newer systems PlayCanvas provides, you are looking to code two things to get that effect using newer UI elements:

  1. Rotate your element entity to face the direction of the swipe. You can find a number of posts here in the forums about orienting an entity to look at a point (lookAt).

  2. Fade out the arrow graphic from end to start. For that you can will need to use a material with an opacity mask which you can animate and scale to get that fade out effect.

Basically play with the offset and tiling of the opacity channel to make the opacity mask stretch or shrink so it increases the fade value.

Here is a related tutorial on how to animate those two material properties:


Hope that helps, good luck.

Not really, I just want to display the swipe hit

Thanks a lot, I’ll try it now. And from swipe should I get the x, y, z axes in world space in order to apply lookAt? Perhaps you have an example of how to do lookAt using a swipe?