Collision Shape: Flipping graphic does not flip collision shape

BigDaveBigDave Member Posts: 2,239
edited December 2015 in Working with GS (Mac)

As I have a hero hitting with a sword on one side and there for having one side alpha larger in the image than the other,
to have space for the sword down.

I had to realize that the new custom collision shape does not flip (horizontally in this case) with the graphic if this behaviour is used.

A way to avoid this is having the hero centered in the image but this would also require the same amount of alpha on both sides which creates a very wide asset.

The expected behaviour would be to flip the Collision Shape with the graphic, so the graphic doesn't have to be perfectly symmetric to be used with the "flip graphic" behavior.

@dgackey

Comments

  • BigDaveBigDave Member Posts: 2,239

    Side Note: Game Salad arcade does ignore the custom collision shapes totally

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2015

    @BigDave said:
    I had to realize that the new custom collision shape does not flip (horizontally in this case) with the graphic if this behaviour is used.

    That makes sense as the flip attribute flips the image rather than the actor.

    @BigDave said:
    The expected behaviour would be to flip the Collision Shape with the graphic . . .

    Personally I think how it currently works makes sense, otherwise we are conflating the actor with the image applied to it, to me they are two separate things.

    Maybe what you are after is a flip actor attribute, which would be useful in all sorts of ways, we know it's possible to flip an actor horizontally or vertically by interpolating its size from, for example, 500 to -500, but unfortunately when the interpolation stops the value that has gone lower than 0 jumps back to 0.

    So . . . . it is possible to have a negative size value (but it's not implemented), this is a situation where a flipped collision shape would make much more sense.

    In your situation I would just have two actors with different collision shapes and swap between them.

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    I noticed this too. Would be very nice to have the collision shape flip with graphics.

    @BigDave said:
    Side Note: Game Salad arcade does ignore the custom collision shapes totally

    HTML5 does not yet have custom collision supported.

    Mental Donkey Games
    Website - Facebook - Twitter

  • BigDaveBigDave Member Posts: 2,239
    edited December 2015

    @Socks
    hm two hero actors - sounds hacky and like a source for bugs by missing to update one of them.

    Since the whole point of Custom collision shapes is to align to the image outlines I still think the best way is to make it part of the flip image.

    As you never want an image not fitting its collision shape.

  • owen_dennisowen_dennis Just a guy, you know. Member, PRO Posts: 236
    edited December 2015

    @BigDave said:
    @Socks
    hm two hero actors - sounds hacky and like a source for bugs by missing to update one of them.

    Since the whole point of Custom collision shapes is to align to the image outlines I still think the best way is to make it part of the flip image.

    As you never want an image not fitting its collision shape.

    I think you could certainly want your image to not fit the collision shape.

    For example, you might want the collision shape to be larger than your image so you can have an actor use a collide function when it gets near something instead of a magnitude function.

    You might also want the collision shape to be smaller than what the image is. So like if you have a dandelion seed you might want players to only be able to catch the seed part instead of the umbrella/fluffy part.

    Or what if you have like a top down game where you make a cross that's like a rotating platform. You have to be on the cross to be able to cross the chasm or something. One way to make it so that the game knows the player isn't on the cross would be to set up collisions so that the "empty space" between the platforms is the collision box, and the platforms have no collisions.

    There's lots of places to explore with custom collision shapes.

  • BigDaveBigDave Member Posts: 2,239

    i see

    than a new option "flip actor"
    will be the best way but unlike to be added soon.

    So I will do the alpha trick and have the hero centered with the extra alpha on the left side.

  • ArmellineArmelline Member, PRO Posts: 5,368

    I would really prefer collision shape not flip with flip image. But I'd be happy with the addition of a couple of "flip actor" attributes.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Collisions in box2d are related to the rigid body aka the actor not the images. When you flip the image it is seperate from the actor aka the rigid box. There is no specific way around this as this is how box2d works. This is why animations don't currently work with custom collisions. Stevej said they are going to work on having animation support.

  • SocksSocks London, UK.Member Posts: 12,822

    @BigDave said:
    As you never want an image not fitting its collision shape.

    Never ? :) I can think of numerous situations where you'd want a different collision shape to the boundary of the displayed image.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @BigDave said:
    @Socks
    hm two hero actors - sounds hacky and like a source for bugs by missing to update one of them.

    Since the whole point of Custom collision shapes is to align to the image outlines I still think the best way is to make it part of the flip image.

    As you never want an image not fitting its collision shape.

    It's not hacky as you say because this is what will happen when they add animation for custom shapes. In box2d rigid body shapes can't be modified at runtime so during each frame a new body replaces the old. The only difference is the code keeps it's association. Plus all you need to do is if your hero is a prototype is make any changes and duplicate the actor and change the spawn selection. Pretty easy to do actually.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited December 2015

    @BigDave said:
    @Socks
    hm two hero actors - sounds hacky and like a source for bugs by missing to update one of them.

    Since the whole point of Custom collision shapes is to align to the image outlines I still think the best way is to make it part of the flip image.

    As you never want an image not fitting its collision shape.

    That's only part of why someone would want custom collisions. You can also make things like boundaries for an entire level, that don't fit a single image or actor but the whole scene, and load the custom collision data into a single large actor with no image for use instead of smaller individual boundaries.

    Or you could make nice interlocking shapes for a chain or rope that use completely different collisions than the actual shape of the image.

    Follow us: Twitter - Website

  • tmanntmann Member Posts: 278

    Although it certainly seems that if you have a collision shape on an image you would normally want it flipped with the image there is no obviously simple way of achieving this. GS will need to write an algorithm to mirror the json data or probably, far easier, allow for an extra collision shape be associated with the flip image switch or loadable from a table, loads of ways to do it I guess. But I assume collision data isn't switchable at runtime anyway like most physics attributes ? ....whatevr

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited December 2015

    @tmann said:
    Although it certainly seems that if you have a collision shape on an image you would normally want it flipped with the image there is no obviously simple way of achieving this. GS will need to write an algorithm to mirror the json data or probably, far easier, allow for an extra collision shape be associated with the flip image switch or loadable from a table, loads of ways to do it I guess. But I assume collision data isn't switchable at runtime anyway like most physics attributes ? ....whatevr

    Yes this is because of how box2d works. Not because GS doesn't want to implement it. A simple read of the box2d manual will clear up why.

  • BigDaveBigDave Member Posts: 2,239

    ye.. I just know that I can't use the custom collision shape also because I like to beta test my games from now on via the Arcade which is a quick way to get a lot of people on it.
    I will create a invisible actor constraining the visible graphic actor on top as I did in creepy again. Maybe next game custom shapes when I can flip em together with my graphic and the they are also working on the arcade.

Sign In or Register to comment.