Is it possible to change the flags of an object?

edited October 2013 in Help request
As title says, I have an arrow object that collide with monsters and the ground. After it hits the ground I wanted it to stop colliding with monsters.

Is it possible?

Comments

  • edited October 2013
    Yes, you can modify the collision flags (& check mask) of parts using orxBody_SetPartSelfFlags/orxBody_SetPartCheckMask.

    You can translate collision flags between their literal version and their numeral version using orxPhysics_GetCollisionFlagName/orxPhysics_GetCollisionFlagValue.

    Lemme know if you have any other issue.
  • edited October 2013
    Thanks a lot, I got it working:
                orxBODY* arrowBody = orxOBJECT_GET_STRUCTURE(currentWatcher->arrow, BODY);
                orxBODY_PART* arrowBodyPart = orxBody_GetNextPart(arrowBody, orxNULL);
                while(arrowBodyPart != orxNULL){
                    orxBody_SetPartCheckMask(arrowBodyPart, 0x02);
                    arrowBodyPart = orxBody_GetNextPart(arrowBody, arrowBodyPart);
                }
    

    I had no idea of the existance of this macro orxOBJECT_GET_STRUCTURE, it is really handful.

    Just wondering, is there any way I can set the collision flags in the ini file that is not numeric.
    Something like:

    [Physics]
    Gravity = (0, 981, 0)
    DimensionRatio = 0.01
    ArrowFlag = 0x0001
    GroundFlag = 0x0002 ; Declaring flags here
    MonsterFlag = 0x0008

    [ArrowBodyHead]
    Type = mesh
    VertexList = (6, 2, 0) # (6, -4, 0) # (12, -1, 0)
    SelfFlags = ArrowFlag
    CheckMask = GroundFlag | MonsterFlag
    Solid = true

    The orxPhysics_GetCollisionFlagValue is not at the API DOC, but I did found it in the headers, still, how do I use it? It needs a name, where does this name comes from?
  • edited October 2013
    Knolan wrote:
    I had no idea of the existance of this macro orxOBJECT_GET_STRUCTURE, it is really handful.

    Yes, it's quite handy to obtain any component attached to an orxOBJECT. :)
    Just wondering, is there any way I can set the collision flags in the ini file that is not numeric.
    Something like:

    [Physics]
    Gravity = (0, 981, 0)
    DimensionRatio = 0.01
    ArrowFlag = 0x0001
    GroundFlag = 0x0002 ; Declaring flags here
    MonsterFlag = 0x0008

    [ArrowBodyHead]
    Type = mesh
    VertexList = (6, 2, 0) # (6, -4, 0) # (12, -1, 0)
    SelfFlags = ArrowFlag
    CheckMask = GroundFlag | MonsterFlag
    Solid = true

    Yes! That is one of the few features that got added since the last release.
    You can simply specify the names in a list:
    [ArrowBodyHead]
    SelfFlags   = arrow
    CheckMask   = ground # monster
    

    If the literal values are unknown, a new numerical value will be assigned to it (keep in mind there can be only 16 totals as that's the limit for collision flags in Box2D).

    If you want to make sure that the same literal flag will have the same value all the time (as opposed to have a value attributed at runtime depending on the order of their creation), you can specify them in config:
    [Physics]
    CollisionFlagList = ground # monster # arrow
    
    That list will expand at runtime if new flags are found/added.
    The orxPhysics_GetCollisionFlagValue is not at the API DOC, but I did found it in the headers, still, how do I use it? It needs a name, where does this name comes from?

    Well, it should be in the API doc you have locally in orx/doc/html/index.html. That version is automatically updated every time a header is modified. (You can track it here: http://buildbot.orx-project.org:8010/waterfall)
    The online version only matches what's in the last release.
  • edited October 2013
    Sorry for the delay of the answer, I didn't have time to test it in the last days.

    I got it working now with the ini file now, it is really great that I no longer have anything hard-coded in the code and in the ini files anymore.

    Thanks a lot.
  • edited October 2013
    No worries,

    glad it works. =)
Sign In or Register to comment.