Jump to content

(Updated:) P2 Physics disable drifting around


tmuecksch
 Share

Recommended Posts

Hey there,

 

I'm currently working on migrating some of my game objects from Arcade to P2 in order to improve collision detection (because AABB sadly wasn't sufficient).

 

But now my player is drifting around like an asteroid in space with a little thruster on it.

 

Like in this code example on phaser.io

 

[i already solved (poorly) this below:] How can I change the player's handling to act like before in arcade physics?

 

  • Can you recommend a tutorial or another resource that explains how P2 actually works, so I can learn to handle it more confidently?
  • If anyone has an Idea how to do get rid of the drifting "the p2 way", I would be very grateful!

 

Thank you guys in Advance!

Link to comment
Share on other sites

For those who will have the same problem in the future:

 

I found a very simple way to achieve this behavior:

var angle = player.body.data.angle + Math.PI / 2;player.body.data.velocity[0] = currentSpeed * Math.cos(angle);player.body.data.velocity[1] = currentSpeed * Math.sin(angle);

The problem is: This disables many features P2 would have given you, for example the player bouncing off walls and such.


If anyone has an Idea how to do get rid of the drifting "the p2 way", I would be very grateful!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...