Jump to content

Search the Community

Showing results for tags 'jumpthrough'.

  • 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 2 results

  1. I'm trying to create a game that involves platforms I can jump through and land on top of. However, when I jump through a platform and land on it, I bounce on top of the platform. The bouncing has to do with the height I dropped from onto the platform. In order to do the jumpthrough platforms, I used the ideas from this thread, and modified them to work with my game. The actual code I'm using in the onPreSolve method is below: world.on('preSolve', function(presolve) { for (var i = 0; i < presolve.contactEquations.length; i++) { var c = presolve.contactEquations[i] var f = presolve.frictionEquations[i]; if (c.bodyA.shapes[0].collisionGroup == GROUND || c.bodyA.shapes[0].collisionGroup == PLATFORM) { var yAxis = p2.vec2.fromValues(0, 1); var y = p2.vec2.dot(c.normalA, yAxis); if (y >= 0){ // check for jumpthrough object // check if moving upwards c.enabled = false //disable contactEquation if (f) { f.enabled = false //disable frictionEquation (solves the stuckInPlatform problem) } if (c.bodyA.velocity[1] < 15 ){ // velocity < 15 - still inside the platform c.bodyA.velocity[1] -= 5; // course correction! } } } } });The only thing that seems like it might be causing the issue would be the course correction, though I wouldn't expect that code to be executed when I am falling and land on top of a platform, since this should check if it is moving upwards on contact. If this is a common problem, please point me to the thread where I can read more about this, because I wasn't able to find it through searches. I've attached a video showing the bouncing. It's more slight in the video than usual, but sometimes it gets to the point that the character is bouncing higher than he is tall. (I apologize for the poor video quality, don't have any screen recording software installed on this computer.) IMG_1733.MOV
  2. here is the testcase: http://test.xapient.net/phaser/ALL/jumpthrough.html i made two versions of the checkOverlap() function.. in the second (commented out atm) i check in both ways but specially for the player velocity.. this leads to situations where the player velo is not enough anymore when "inside" the platform and bounces back really fast.. the first version somehow baffles me.. if the fist body is my player he always is moving UP.. therefore no further checks are needed.. i just let him through... BUT i honestly don't know the implications of that.. it's definitely not field tested the moving platforms would also work with a simple tween where i tween the velocity but with my custom function and some predefined attributes (bounds, velocity) that can also be configured in tiled so every platform already knows where to move, this is more precise.. @rich.. if this would be somehow suitable as an example feel free to copy/adapt/rewrite the code a small piece of the code: game.physics.p2.setPostBroadphaseCallback(checkOverlap1, this);function checkOverlap1(body1, body2) { if (body1.sprite.key === 'mario' && body2.sprite.key === 'platform'){ return false; } //for some reason if mario is body1 not body2 he is moving from below - thats all we need to find out to let him through return true;}function checkOverlap2(body1, body2) { if (body1.sprite.key === 'mario' && body1.velocity.y > 0 && body2.sprite.key === 'platform'|| body2.sprite.key === 'mario' && body2.velocity.y > 0 && body1.sprite.key === 'platform'){ return false; } // this checks if mario is jumping return true;}
×
×
  • Create New...