[SOLVED] Replacing Sprite with with keyboard input

I’m trying to do when specific keyboard input is pressed, the Sprite should be replaced with other Sprite of my choice. I was searching in API reference but I might missed something.

Can anyone point me to specific part of API documentation?

Quick example made here: https://playcanvas.com/editor/scene/1129019

Please space to change the sprite.

1 Like

Ok that what I need but if I have nested entity how to call that entity? Example of hiearchy of entity in next photo.
Screenshot from 2021-04-12 19-31-37

Ok, I found the answer to my question

It needs to be like this

this.player = this.entity.findByName('Player');
this.player.sprite.spriteAsset = this.sprite_right;
1 Like