Hey guys, I was wondering if there is anyway to make a weapon follow my character, so it appears to be in his hand.
Use a container.
Hey @Milton, thanks for the example but I’m not so sure that I understand it. I’m still new to Phaser, so if you could provide a brief explanation of the key points, that would really help.
A Container can contain game objects, like sprites. So when you add sprites like player and weapon to a container, and move the container, it moves both player and weapon.
It’s basically a shortcut to moving both player and weapon. You could just position weapon relative to the player, like weapon.x = player.x + 15 or something. But when you have a lot of sprites, and maybe rotation etc, it might be handy. I usually don’t bother…
1 Like
Thank you!