Changing Self.Physics.movable

simo103simo103 Member, PRO Posts: 1,331
edited November -1 in Working with GS (Mac)
I have an actor that I can drag and move. On touch I set an attribute to tell the game that it is being moved. That attribute triggers others Self.Physics.movable to false so the other actors don't move.

It doesn't work for me. (Note there are collision behaviors so the actors can be stacked and exploded).

Can I set the movable to false by a rule? And at the same time have collision behaviors so the moving actor can stack on the others?

thanks.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Unfortunately, you cannot change the Movable attribute at runtime.
    Well, technically you CAN change it, but it has no effect.
  • simo103simo103 Member, PRO Posts: 1,331
    thanks .. that clears up a lot.

    Do you think setting and holding those actors to their x and y position whilst the other actor is being moved is the way to solve this?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    It's a tough call. If you are dragging an actor around by constraining its x and y to the Mouse, those constrains will override the physics system.

    You might have to make duplicate Actors, one that has its movable set to true, and one to false.

    When you pick up an actor, spawn the nonmovable actors in place of the movable ones - then destroy the movable ones. When you release the actor, switch them back. Definitely a pain, but it might be the only way.
  • MotherHooseMotherHoose Member Posts: 2,456
    index all the moveable actors...
    game.Attribute ActorMoving = 0 (Index type)

    on each actor
    an attribute myIndex# = (an assigned # for that Actor)

    [Rule]
    when Touch is pressed
    ---ChangeAttribute game.ActorMoving To: self.myIndex#
    ---[Rule]
    ---when game.ActorMoving = self.myIndex#
    -----ConstrainAttributes so you can drag

    [Rule]
    when Touch is released
    ---ChangeAttribute game.ActorMoving To: 0

    I did this with 25 drag-able actors...
    perhaps it will work for you... though you may have to add a 'busy' boolean to eliminate possible multi-touches interference.

    MH
  • simo103simo103 Member, PRO Posts: 1,331
    thanks fmp and MH ... will give those both a try tomorrow to see how they work and will update this post incase others are interested.
  • simo103simo103 Member, PRO Posts: 1,331
    fmp ... my gameplay has a trigger (switch) luckily so I set my actors to fixed which allowed the moveable actor to not effect them and then I spawned moveable actors in their place (destroyed the fixed ones) when the switch was hit and it works perfectly.
    Thanks for the help.

    MH .. thanks for your suggestion also .. luckily I only needed to move one actor so the above worked but I have kept your note on file as it looks handy for a future project.
Sign In or Register to comment.