How do I make a sword object be connected to the player. Also how do I swing the sword with a hitbox once connected?

I searched up this a few times, and containers were mentioned. But, Im not sure how to use a container, make it turn to a certain point when a button is clicked, then go back (sword swing animation). And Im not sure how to connect it with the player without putting both in a container, which would cause them both to turn when sword swing animation is activated.
Its my second time using phaser, and I am trying to create a dungeon crawler.
Thanks 4 help in advance

There may be some tutorials on this somewhere.

  • If you’re using Arcade Physics, you can enable a container for physics and move it with velocity.
  • You can get the pointer world coordinates in a click callback and calculate the angle toward it, then tween a game object angle toward that and back.
  • If player and sword are in a container, you can still move or rotate them separately from each other and the container.
1 Like