Jump to content

Search the Community

Showing results for tags 'P2. physics'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hi all, I've been playing around with Phaser's P2 physics for a game set in space... I have a very simple starship to which I give a triangular shape with addPolygon and then planets with circle shapes (setCircle). This is an example of the code: //For the playerplayer.body.addPolygon({'skipSimpleCheck': true}, [[this.width/2.0, 0], [0, this.height], [this.width, this.height]]); // A simple triangular shape//For the planetplanet.body.setCircle(radius); After doing a clearShapes() for both. However, the collision seems to be shifted on the player - when it hits on the top, it hits while it's still a few pixels from the surface, while on the bottom, it overlaps a bit before hitting. I suppose this is the consequence of P2 calculating the center of mass of the shape and then overlapping it to the middle of the sprite. Is there any way to avoid/fix this? I tried manually changing player.body.offset but it didn't work. Thanks! EDIT: Ok, I don't know how to tag this as solved but I did find a solution for this. From what I see, yes, P2 finds the center of mass and then automatically overlaps it to the .5, .5 point of the sprite - my solution was to simply increase the sprite's size, giving it some more empty space to shift the center downwards and have it coincide with the place where I wanted the center of mass to actually be. It's a bit rough but I could afford it given that the sprite was very small anyway. Would be nice to be able to avoid this though.
×
×
  • Create New...