Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental: Platformer actor collision #1037

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

um3k
Copy link
Contributor

@um3k um3k commented Jan 31, 2022

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature

  • What is the current behavior? (You can also link to an open issue here)
    Platform mode does not support solid collision between actors and the player

  • What is the new behavior (if this is a feature change)?
    Actors have a 'solid' property, when it is enabled, the player will collide with them like a wall, and will move along with one that it is standing on.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    I don't believe so.

  • Other information:
    Still need to investigate optimization. It works OK in color mode, but sprites get jittery in DMG mode. There are also issues with how the player moves with an actor it is standing on, and collision events currently do not trigger on solid actors.

@darkhog
Copy link

darkhog commented Feb 2, 2022

Once you are done with this, could you please also do the same for the adventure mode? Code shouldn't be that much different, tho in adventure the moving along with actor would have to go.

The reason for this is that in adventure mode currently there is no possibility of creating secret entrances that only become passable once certain conditions are met as map collision is static and you can pass through actors that would normally block players from entering before they met the necessary conditions.

@um3k
Copy link
Contributor Author

um3k commented Feb 2, 2022 via email

@darkhog
Copy link

darkhog commented Feb 2, 2022

That's awesome. Thank you!

@maxoakland
Copy link

This is so cool. I hope you can get this implemented because we’ve needed this feature for a loooong time

@godai78
Copy link

godai78 commented Feb 21, 2022

Only now have I found it. This one sparks joy.

@godai78
Copy link

godai78 commented Apr 29, 2022

Will it make it into 3.1?

@maxoakland
Copy link

Will it make it into 3.1?

Looks like there are still some conflicts that must be resolved

@chrismaltby
Copy link
Owner

Hi @um3k Just to let you know, after a very long time I have finally been testing this and definitely interested in merging.

Not sure it's going to be 3.1 though, I'm starting to feature freeze on what makes it in to 3.1 and I'm still having a few issues with it.

  • In Platform scenes if stood on a moving actor, that is solid in all directions, while it is moving upwards and you're either at the left edge jumping right, or the right edge jumping left you snap back to the side of the platform (think this is probably the horizontal collision detection kicking in when it shouldn't). From what I can tell as long as the vertical moving platform just has "Top" collisions turns on, or your fully solid actor is either stationary or only moving horizontally then it all works great.
solid_bug.mp4
  • Possibly related vertical moving actors set to fully solid in Adventure also do some odd snapping when colliding with top / bottom edges (left/right work correctly)
solid_bug2.mp4
  • I think the quick check you do pre running the full collision check might be too small a range for some larger actors, if I'm understanding what you're doing correctly increasing to + 3 and > 6 help a bit
             ((UBYTE)((BYTE)(PLAYER.pos.x >> 8) - (BYTE)(sol_actor->pos.x >> 8) + 3) > 6) ||
            ((UBYTE)((BYTE)(PLAYER.pos.y >> 8) - (BYTE)(sol_actor->pos.y >> 8) + 3) > 6)) {

By the way the persistent actors feature ("Keep Running While Offscreen" checkbox on "On Update") and recent optimisations to actors_update() and vm_actor_move_to() + some better offscreen detection we wrote recently were to prepare for merging this feature.

Thanks for putting this PR together, definitely is a great feature that people will make lots of use of!

@um3k
Copy link
Contributor Author

um3k commented Jul 25, 2022 via email

@jessemillar
Copy link

jessemillar commented Sep 29, 2022

I fixed the two merge conflicts locally and built an adventure scene. It works pretty well for 16x16 actors (I didn't try any larger actors). The one "bug" I found is that solid actors pushed with the "Push Actor Away From Player" event do not always collide with other actors that are set to solid on all sides. I was able to consistently push a solid box to the right and have it phase through another solid box. A solid box pushed vertically DOES stop properly when encountering another solid box.

Also, I found that copying and pasting an actor with the various solid checkboxes checked does not set those same boxes on the pasted actor.
image

@godai78
Copy link

godai78 commented Sep 29, 2022

That's impressive work, looks like it's closer than ever before :)

@jessemillar
Copy link

I just made my own PR branching off the content of this PR. Attempted to fix the merge conflicts and issues found by me and Chris mentioned in the comments above. #1232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants