Simple texture exchange

Good afternoon,

I would like to know how I can, in the simplest possible way, change the texture of an object, as in a sprites animation. I want to do it in a very simple and basic way. Thank you very much.

Animating textures is your best bet here: http://developer.playcanvas.com/en/tutorials/animated-textures/

Steven, Thanks a lot for your help, but this tutorial I’ve seen, but wanted something simpler …
I could not understand or apply in my test …

Which part are you having trouble with understanding?

Basically from the beginning … I copied and pasted the code in my test project but it did not effect any … I made a 50x25 pixel tile having two 25x25 pixel frames, I put in the material and the object and made for so Press the up arrow to change the frame … but it did not work … wanted something very simple even just to do a 2d animation of a character and a change of frame for menus and etc … could you understand?

Do you have a link to the project?

As I am new to PlayCanvas I have to ask …
How do I generate this link for you?

If this is a public project, you just share the URL of the project’s homepage

https://playcanvas.com/project/458262/overview/projeto-teste-01

Hmm… I can’t see the code where you’ve tried to animate the texture? Mudar Textura is virtually empty?

Yes … because it did not work and I deleted …
Precisely because I do not know where to start …

I took some examples that I found and tested …

I’ve created a simpler version of the changing frames in a sprite sheet that doesn’t have the animation. http://developer.playcanvas.com/en/tutorials/sprite-sheets-with-textures/

Hopefully that will be easier to understand.

Many thanks for the help Steven …
Thank you very much …
I think I understand now …
I’ll give a look at this example …

Good afternoon Steve,

I edited the code only by taking the mouse click event and letting it run alone … How do I slow down the animation? Do you have to change the value of “dt”?

Thanks a lot for the help.

That’s where you have to look at the previously linked example: http://developer.playcanvas.com/en/tutorials/animated-textures/

In that sample, you can set a framerate for the animation. Essentially, it keeps track of how long it has been since the last frame change and moves to the next frame every N seconds. A framerate of 20 means it changes frames 20 times a second which means that it changes to the next frame every 1/20th of a second.

Many thanks Steven …