• Content count

  • Joined

  • Last visited

  1. jeespu

    P2 - rotate to velocity?

    Hi. I'm making a game where you shoot an arrow that uses gravity to fall down. The purpose is to hit birds with that arrow. Currently I have a system, where you drag mouse on the playfield to adjust the power at which you shoot. This is done in P2 physics by setting x and y velocity for the created arrow object, in relation to the cursor's location and the "firepower"-variable. First: should I implement that kind of system with "thrust" and "angle" instead of just setting velocities? Is there any actual difference? Second: my main problem here is the angle. I can set the angle during object creation (to -90 so the arrow points upwards), but it won't change direction until it collides with a bird. How do I recreate a "rotateToVelocity" (from the weapon plugin) effect in P2? I've been struggling with this issue all day. It shouldn't be this complicated to do. Here's my code:
  2. jeespu

    P2 objects and update

    Hello. I'm currently developing my first Phaser game for a school project. It's a simple bow and arrow shoot-em-up, where you shoot birds flying above you. I was using arcade physics up to the point I realized it's kind of impossible to make the arrow head collide with the birds "logically". Therefore I had to switch to P2. The birds had a simple function: fly to the end of the playfield and relocate back to their starting point once they're out of the playfield. This was done inside the update function. When I made the birds P2, suddenly I can't access them via the update function anymore. Here is the github link for the main game code: So basically my question is, how do I access P2 objects from the update function? I also need to make the arrow (created with the weapon plugin) a P2 object. How would I go about doing that? I'm confused with this whole P2 concept, but I know it's necessary for this kind of collisions. Also feel free to spot other "instances of bad practice" if you happen to spot them.