Actors get "stuck" when on top of each other

TerrellTerrell Member Posts: 7
edited November -1 in Working with GS (Mac)
I'm trying to make a board game, and am finding that when one actor is on top of another, they get "stuck" together (one is under the other, and all subsequent moves, they move together).

I tried a Collide rule, so they wouldn't get over or under each other, but then if I move a piece onto the board, the piece I'm moving throws all the pieces already on the board all over the place.

Suggestions?

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    Try using when touch is inside rather than when touch is pressed...

    in the pressed action both actors are responding... in the inside action only when touch is within the borders of the actor does that actor respond.

    a Z axis would allow better control.

    MH
  • TerrellTerrell Member Posts: 7
    MotherHoose said:
    Try using when touch is inside rather than when touch is pressed...

    in the pressed action both actors are responding... in the inside action only when touch is within the borders of the actor does that actor respond.

    a Z axis would allow better control.

    MH

    Thanks for the reply. My actors are the same size (they are pieces for a board game). So when they get on top of each other, they have the same sized borders, one piece is hidden under the other, and when touched, both pieces respond at the same time - they are "stuck" together.

    Changing it to "touch is inside" makes it even worse. As one piece moves over another it "picks up" the second piece, and they are "stuck" together.

    Is there a way to only select the top piece?

    Another way I thought about would be to turn on "Collide" - then the two pieces that are "stuck" together would move away from each other. But then I'd want to turn "Collide" off again, so a piece could be moved across the board without disturbing other pieces already there.

    Is there a way to turn off "Collide" once it's been turned on?
  • FatalCrestFatalCrest Member Posts: 113
    Have an attribute called Touchable or something and give seperate attributes of Touchable to every actor, so when its whoever's turn, set the Touchable attribute to true just to the one actor.

    And then your rule with your "touch inside", add another requirement with the Touchable Attribute must be true
  • MotherHooseMotherHoose Member Posts: 2,456
    okay see that problem...

    think you are going to have to create a gameAttribute ... boolean and name it something like busy

    then on game piece...
    [Rule] when (All)
    touch inside
    game.busy = false
    ...ChangeAttribute game.busy = true
    ...then nested [Rule] game.busy = true
    ......then the drag/do stuff
    ...then nested [Rule] touch is released ChangeAttribute game.busy = false

    If you get it to work once... then you can drag the rule to myBehaviors and just apply to the other pieces from there.

    MH

    EDIT: what FatalCrest said!
  • FatalCrestFatalCrest Member Posts: 113
    Thanks for placing it out MotherHoose, I was gonna eventually do that if Terrell needed more help x)
  • TerrellTerrell Member Posts: 7
    Thanks for offering help! It's really appreciated!

    I just started a few days ago with GS, so I'm really new at this.

    I'm not sure I followed your instructions completely, because it doesn't work.

    I made an Attribute (boolean) called DragDrop
    And move pieces with a Behavior I call "Move" that looks like this with two rules:

    Rule: When (All)
    touch pressed
    ...Change Attribute self.DragDrop = true
    ...Otherwise Change Attribute self.DragDrop = false

    Rule: When All
    Attribute self.DragDrop = true
    ...Constrain Attribute self.Position.X = game.Mouse.Position.X
    ...Constrain Attibute self.Position.Y = game.Mouse.Position.Y

    So each piece can be moved by dragging and dropping. This seems to work fine.

    Now, let me put what I think you said, so please help me see where I'm wrong.

    I made a Game Attribute and called it "Busy"
    Rule: When All
    touch inside
    Attribute game.Busy = false
    ...Change Attribute game.Busy = true
    ...Rule when All game.Busy = true
    ......Move
    ...Rule: When All touch is released
    ...Change Attribute game.Busy = false

    I'm probably not getting the nesting correct. I've tried different things, but when I click on the piece, it doesn't move.
  • expired_012expired_012 Member Posts: 1,802
    Something I got a while ago:

    2 game integer attributes:
    - ID creator (Value:1)
    - WhichID (Value:0)

    Attributes inside of actors that you will be moving around:
    (all integer attributes)
    -ID (0)
    -OriginX (0)
    -OriginY (0)
    -ChangeX (0)
    -ChangeY (0)
    -OriginTouchX (0)
    -OriginTouchY (0)

    -----------------------------------------------------------

    Change attribute: self.ID to game.IDCreator

    Change attribute: game.IDCreator+1

    ------------------------------------------------------------

    RULE:

    When touch is pressed:

    change attribute: game.WhichID to self.ID

    otherwise

    change attribute: game.WhichID to 0

    --------------------------------------------------------------

    RULE:

    When attribute game.WhichID=self.ID

    change attribute: self.OriginX to self.position.X

    changé attribute: self.OriginY to self.position.Y

    change attribute: self.OriginTouchX to game.Touches.Touch 1.X

    change attribute: self.OriginTouchY to game.Touches.Touch 1.Y

    CONSTRAIN ATTRIBUTE: self.ChangeX to game.Touches.Touch 1.X - Self.OriginTouchX

    CONSTRAIN ATTRIBUTE: self.ChangeY to game.Touches.Touch 1.Y - Self.OriginTouchY

    CONSTRAIN ATTRIBUTE: self.position.X to self.OriginX+Self.ChangeX

    CONSTRAIN ATTRIBUTE: self.Position.Y to self.OriginY+Self.ChangeY
  • TerrellTerrell Member Posts: 7
    Thanks. I'll need to study that for a while to figure out what it means. I'm still a rank beginner.

    I did discover I can move a piece much more simply by just doing this:
    Rule:
    When All Actor touch pressed
    Constrain Attribute self.Position.X to game.Mouse.Position.X
    Constrain Attribute self.Position.Y to game.Mouse.Position.Y

    So I'm not sure what the purpose of making an Attribute called DragDrop was, or setting an "Otherwise" unless it keeps things clean?

    So Artonskyblue, I create 2 game integer attributes, and inside each Actor 7 integer attributes.

    Then the behaviors and rules above will move my piece, and not cause them to get stuck to each other when they overlap? I'll have to try it and see what happens. Now I think I need some sleep, I'm up too late! Thanks for the suggestion.
  • expired_012expired_012 Member Posts: 1,802
    @Terrel, yup that should make the pieces move and not overlap. Some of that came from my memory so if you have any problems let me know.

    Remember, you dont have to put those rules and attributes in each actor individually. The rules will be the same in each actor, so just copy and paste the actor as many times as you need, and you can change the image of it easily as well

    and yeah the self.pos.x/y to mouse.pos.x/y works but that will cause overlapping
  • expired_012expired_012 Member Posts: 1,802
    Have you got it all worked out now?
  • TerrellTerrell Member Posts: 7
    I have not tried it quite yet, with the weekend I was pretty busy, and soon Thanksgiving will be upon us, but I have it saved from your post, and as soon as I can I'll try it out and get back to you (I know it can be frustrating when people don't post back after helping them). Thanks for checking back.
Sign In or Register to comment.