Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Platformers and Box 2D

Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6885

    Matt

    Greetings,

    Please excuse me if this has been brought up before.

     

    I am experimenting a bit with the Physics engine and a tiled based (old school) platformer design.  I have tiled out the ground as BoxColliders, created my BoxCollider player and have him moving across the ground but he would get stuck in one spot here and there seemingly randomly.  I figured he was getting stuck in spots between some of the ground colliders (which is a bummer) and from what I have read online, I was correct.

     

    The easy way to fix this problem would be to simply change the player into a Circle Collider.  I have experimented with this and even though this seems like a quick fix, it does not address the player needing to get close to the edge of a platform (within the circle’s radius) and then rolling off the platform on its own as it naturally does because it is a circle.  What I see needing is the front part of the player Body collider being a circle and the back part being a Box OR I from what I have read I could keep the player a Box and use some type of edge chaining method.  The Body would also need to keep track of the Circle being the leading Collider shape for the direction the player is facing

     

    I thought I would bring up this discussion to see what might be recommended for a Felgo game.  The levels in this game will be larger than the screen size, a camera will be attached to the player, I intend to use the in-game level editor to create levels and I always prefer the simplest solution.

     

    Thanks!

    • This topic was modified 10 years, 1 month ago by  Xevoius.
    #6890

    Matt

    Body.Kinetic

     

    Heading down this path next for the player entity.

    #6899

    Matt

    Ok, I found the functions I need for smooth movement with tiled BoxColliders by turning off and on the collsionTestingOnlyMode.

    fixture.onBeginContact: {           
                if(player.y <= tile.y)      collisionTestingOnlyMode = false //ground
                else if(player.y >= tile.y) collisionTestingOnlyMode = false //ceiling
                else if(player.x <= tile.x) collisionTestingOnlyMode = false //left wall
                else if(player.x >= tile.x) collisionTestingOnlyMode = false //right wall
     }
    
    fixture.onEndContact: { collisionTestingOnlyMode = true }

     

    I am still unsure about sticking with a Body.Dynamic for my player.  I had this very same issue when I was prototyping in Unity.  I ended up applying velocities and handling ground and collision detection myself to get that old school feel.

    #6904

    Christian
    Felgo Team

    Hi,

    your solution sounds pretty good to me.

    You can also get in contact with the developers of Pharaoh’s Escape (you can download it for iOS & Android in the app stores), which  had similar problems: they used a CircleCollider in the end and also laid out their ground with tiles.

    I think their platformer behavior is really well done – do you have questions you would like to discuss with them, and should I send them the link to this froum thread?

    Cheers, Chris

    #6911

    Matt

    I will look their project up and contact them directly.  Thanks for pointing me in their direction and I think I am making some progress here.

     

    Thanks Chris.

    #6914

    Christian
    Felgo Team

    Sounds good!

    If you share your solution afterwards this would be a great help for the community!

    Cheers, Chris

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded