Olliebrown

Members
  • Content count

    5
  • Joined

  • Last visited

  1. Olliebrown

    Phaser P2 DebugBody - Visualizing Rotation (possible bug)

    I just integrated that into the codepen to test and it seems to work for my case. Now that it is drawn correctly, I also noticed that the placement of the rotated collision box made the 'dude' sprite rather ... um ... well endowed! Thanks again, Seth B.
  2. Olliebrown

    Phaser P2 DebugBody - Visualizing Rotation (possible bug)

    A ha! Perfect. I was just looking at that exact function and noticed that it was ignoring angle. Thank you!
  3. When adding a rectangle to a p2 body you have the option to specify a rotation in radians for the shape which it appears is just passed directly on to the p2 shape constructor (hence the need for it to be in radians instead of degrees as are used elsewhere in Phaser). I find that if I use any value other than 0 for a rotation, the shape is properly rotated however drawing of the body via the debug parameter ignores the rotation. Here is a quick codepen illustrating the bug. The character should have a long protrusion coming out the bottom achieved with a rotated rectangle. The physics collision seems to indicate that the rotation has occurred correctly, however the debug shape is not drawn rotated. Notice that he appears to sit a little ways off the ground due to the un-rotated debug visualization of the shape. It seems to me this must be a bug (or maybe a limitation of the debugbody drawing system) but I thought I would post here first for thoughts. I will likely dig in and see if I can find a fix / workaround for this. Phaser P2 DebugBody rotation bug (codepen)
  4. Olliebrown

    Phaser P2 Physics - Apply Force

    Well that certainly confirms that it works!! Thank you for the concise and well organized example. I need to see if I can integrate it better for myself. I think the key idea you are doing that I am not (and should be) is applying the gravity force at all times. I am curious to figure out why that makes a difference but it certainly seems more sound from both an integration and physics standpoint. Changing it in the middle of the game like I am might prove problematic! I'll work on this when I have time and check back with results. Thanks again! Seth B.
  5. Olliebrown

    Phaser P2 Physics - Apply Force

    I am attempting to apply force manually to a sprite that has a P2 physics body. My hope is to achieve the designable jump described by Kyle Pitmann in his GDC Talk below. In this he derives equations for a jump arc that are controlled by the height, footspeed, and how long the jump should last. It will give you a gravitational force and an initial velocity to achieve those parameters. Everything I do to try and set a manual force on the P2 body is being ignored. Here is what I have: Gravity on the body is disabled via body.data.gravityScale = 0 I then try and initiate a jump using my precomputed initial velocity and gravitational constant as follows: let vx = config.WALK_SPEED sprite.body.force.y = this._jump_grav_start * vx * vx sprite.body.velocity.y = this._jump_vel_start * vx Afterwards I dump 'force' to the console and it is always zero no matter what I try to set it to. Am I just missing something fundamental here about how you apply a force in P2? Seth B. )