hexus / phaser-arcade-slopes

:triangular_ruler: A Phaser CE plugin that brings sloped tile collision handling to the Arcade Physics engine
MIT License
127 stars 16 forks source link

Snaps to square even when snap is set to 0 #21

Closed iCodeForBananas closed 7 years ago

iCodeForBananas commented 8 years ago

Video example of https://rangersteve.io https://streamable.com/koh2

Just a consts file

    // Slope Plugin
    SLOPE_FEATURES: {
        acceleration: 1500,
        bounceX: 0,
        bounceY: 0,
        debug: 0,
        dragX: 1300,
        dragY: 0,
        enableGravity: true,
        frictionX: 0,
        frictionY: 0,
        gravity: 1100,
        jump: 400,
        minimumOffsetY: 1,
        pullDown: 0,
        pullLeft: 0,
        pullRight: 0,
        pullUp: 0,
        snapDown: 0,
        snapLeft: 0,
        snapRight: 0,
        snapUp: 0
    },

Where I set the player's slope very similarly to how it's done in the demo.

const body = this.player.body

    this.physics.arcade.gravity.y = GameConsts.SLOPE_FEATURES.gravity

    // Add a touch of tile padding for the collision detection
    body.tilePadding.x = 1
    body.tilePadding.y = 1

    // Set player minimum and maximum movement speed
    body.maxVelocity.x = GameConsts.MAX_VELOCITY_X
    body.maxVelocity.y = GameConsts.MAX_VELOCITY_Y

    // Add drag to the player that slows them down when they are not accelerating
    body.drag.x = GameConsts.SLOPE_FEATURES.dragX
    body.drag.y = GameConsts.SLOPE_FEATURES.dragY

    // Update player body Arcade Slopes properties
    body.slopes.friction.x = GameConsts.SLOPE_FEATURES.frictionX
    body.slopes.friction.y = GameConsts.SLOPE_FEATURES.frictionY
    body.slopes.preferY    = GameConsts.SLOPE_FEATURES.minimumOffsetY
    body.slopes.pullUp     = GameConsts.SLOPE_FEATURES.pullUp
    body.slopes.pullDown   = GameConsts.SLOPE_FEATURES.pullDown
    body.slopes.pullLeft   = GameConsts.SLOPE_FEATURES.pullLeft
    body.slopes.pullRight  = GameConsts.SLOPE_FEATURES.pullRight
    body.slopes.snapUp     = GameConsts.SLOPE_FEATURES.snapUp
    body.slopes.snapDown   = GameConsts.SLOPE_FEATURES.snapDown
    body.slopes.snapLeft   = GameConsts.SLOPE_FEATURES.snapLeft
    body.slopes.snapRight  = GameConsts.SLOPE_FEATURES.snapRight
hexus commented 8 years ago

If you comment out this line in your copy of the plugin, does it fix the issue? If not, then something else is causing this.

Try also updating to v0.2.0-alpha if you haven't yet. It contains a restriction whereby collisions are only resolved if a body is moving into a collision normal.

I'll be able to look at this a little more at a later date, as I'm somewhat ill today. :mask:

iCodeForBananas commented 8 years ago

Ok going to try this out today and I'll get back to you.

iCodeForBananas commented 8 years ago

It still appears to be happening, it's pretty minor though.
Just to be sure I commented out the line on 498 because it moved.

hexus commented 8 years ago

M'kay, hopefully I'll be able to reproduce this at some point and work out what's going on.

iCodeForBananas commented 8 years ago

@hexus Is there a way to disable the snap functionality? It tends to happen a lot when I'm moving very quickly.

hexus commented 8 years ago

It's disabled completely unless any of these values are non-zero:

https://github.com/hexus/phaser-arcade-slopes/blob/v0.2.0-alpha/src/ArcadeSlopes/SatSolver.js#L287

So what you're seeing is likely because of the tunnelling issue you mentioned in #8, except in this case they're not falling through a tile, they're moving some way into it without any steps in between.

iCodeForBananas commented 8 years ago

@hexus When we finish this build I'll test this out just to confirm and close this issue.

hexus commented 8 years ago

Cool. :+1:

hexus commented 7 years ago

I've looked over the code again recently and it appears as though snap was running even with the values set to zero! Sorry that I missed this.

I'm actually thinking of removing the solution entirely, as the "pull" mechanic is a much nicer way of solving sticky tiles.

This will either be fixed, or the feature removed, in v0.2.0.

iCodeForBananas commented 7 years ago

@hexus I was literally trying to find this yesterday because I had players mentioned it happening. I just ended up removing all of the snap stuff in a local build of the plugin.

hexus commented 7 years ago

I think I'll remove it. :grin:

hexus commented 7 years ago

Fixed by the above! Will be in v0.2.0, and the feature itself will probably just be removed. :+1:

Planning to get it released pretty soon, so michaeljcalkins/rangersteve-ideas#239 should be sorted soon. :wink: