Forums

OverviewV-Play 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 V-Play 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 4 years, 9 months ago.
    #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
    V-Play 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
    V-Play 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support