need help getting numerous pairs of objects to work together

part12studiospart12studios Member Posts: 620
edited July 2012 in Working with GS (Mac)
Hi there,

What i'm stuck on here is what if i want to have say.. a hit box graphic that is different (bigger) than the art itself.. my thought would be to have an invisible box simply move with the object. my understanding is that it would be easy with a single object to do a constraint, but what i find confusing is what if there are 10 enemies and each one needs one of these boxes to move with each enemy as its spawned. How would this be done, or maybe there is a better solution?

To better explain why i'd want a different hitbox, maybe even several would be in my case where we're talking about cars moving around. i'm working to make the cars intelligent and interact with each other as they move around, but then when it comes to bullets hitting if the graphic was too big, bullets would register hitting before they reached the graphic. however even if that could be handled differently, the real mystery to me is how to get multiple objects to "pair off" and behave individually together.. and have other "couples" do the same.

I guess another analogy would be ballroom dancing.. you have men and women.. you spawn more and more but want them to be able to connect and then move as each newly formed couple needs to move around the room.

Thanks!
Caleb

Best Answer

  • MotherHooseMotherHoose Posts: 2,456
    Accepted Answer
    @part12studios … ah … the designPhase of a game!

    what really has to be in the scene at load time?

    we just so automatically place things like the background; score; timeDisplay; start/reset buttons; back/next buttons; playerCharacter … etc.

    and … perhaps we should rethink those choices when doing the scene layout…

    in your scenario the enemies and their hitSensors are functionally interactive …
    so the 10 enemies should be given offScreen locations and null images
    with 1st behavior: changeAttribute: self.Image To:

    then add the sensors for those enemies unlocked … with correct constrains

    having 20 or more actors without imageDrawing at load time is very fast

    let a controlActor handle the spawn of the background/other actors from prototypes
    … even the player can be spawned when its rules/behaviors are intense

    actors in a HUD layer … can also be spawned by an actor in that layer
    … or another controlActor in the HUD layer

    layout the scene with all elements in correct layer and position
    decide what can be spawned … create controlActors to do spawns
    when ready … delete the spawnedActors from the scene

    image MH

Answers

  • jn2002dkjn2002dk Member Posts: 102
    edited July 2012
    For the first issue the only way i know to do that in GS is to constrain a game variable for each x and y of the actor you want a hitbox attached to which is cumbersome but possible. Maybe someone else has a better way of doing it

    For the second part, if you want them to pair up like in your ballroom dancing analogy you can assign each type of actor a variable to describe them like man=true or woman=true or make a single integer where each value represents a type and then check for that in your collision rule. Man=1 woman=2 etc. Does that make any sense?
  • part12studiospart12studios Member Posts: 620
    crazy day today.. kept trying to get into my project but then i'd get pulled into something else, but now about the suggestions.

    @jn2002dk yea the constraint thing sounds good, but it seems like this is only good for one object.. if i have a spawner cranking out bad guy after bad guy, how does each new hit box know how to pair off with the right object? I can spawn a car to appear and to have that car spawn a hit box actor on top of it, but then it would leave the box behind because the box doesn't know to stick with it. With the 2nd part, my analogy was mostly to drive home the same issue of having unique one item stick with another dynamically.. each time a new male dancer is spawned, he would have an accompanying female dancer who moves with him as a "child" of the male dancer..

    @MotherHoose so are you suggesting i not use a spawner but instead have a stage with pre defined enemies off stage that just get called on at certain times? I can see how unlocking numerous unique objects on the screen would be a solution.. because then i could access info from other objects in the stage.

    Thanks so much for the feedback!

  • jn2002dkjn2002dk Member Posts: 102
    @part12studios

    Yea, i understand now. Sounds like MotherHooses solution is the way to go
  • part12studiospart12studios Member Posts: 620
    ugh.. i was hoping that isn't the case. at least its easy to create new scenes so each level can have its own combination of vehicles, order of release and so forth. man thats going to be tricky, but at least its good to know i should be able to manage this approach.

    its just so nice to have a "fire and forget" spawner kind of system. oh well :)

    Thanks!
Sign In or Register to comment.