Causing actors to become non-movable once hit

studiocritystudiocrity Member Posts: 14
edited November -1 in Working with GS (Mac)
I'm making a game and am trying to make blocks become non movable when they hit another block, however the movable attribute cannot be changed in game so i am not sure how to stop them moving (i have gravity acting on them).

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi, yes, it's a bit of a nuisance that you can't change Moveable during gameplay.

    One workaround is a bit of a pain which I don't think you'll like much, especially if this is going to be happening all the time in your game; still here it is:

    Make 2 integer attributes called MBx and MBy, and a boolean, ReplaceB01.

    Let's call your first moving block MoveBlock for this example. Make a copy of MoveBlock in the scene but put outside of the screen area. Make it an instance (unlock it's Rules). Make it non-moveable. Delete any Rules that might be there; put

    When ReplaceB01 is true

    Change Attribute self.Position.x to MBx
    Change Attribute self.Position.y to MBy

    When the first moveable block is collided with, in its Rules:

    Change attribute ReplaceB01 to true
    Change Attribute MBx to self.position.x
    Change Attribute MBy to self.position.y
    Destroy attribute

    The above is off the top of my head and so is untested and might need tweaking a bit, but the basic principal is there. For instance, in the non-moveable version, you can still put collision Rules.

    A variation is to have the immovable block replace the moving one with a Spawn Behavior.

    Can't think of anything more straightforward at the moment, maybe another member will; fingers crossed.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • studiocritystudiocrity Member Posts: 14
    thanks for the suggestion though this may be timely to implement as i have five different types of blocks occurring many times over in the game, spawning immovable blocks may work, I have had some success with:

    when block is hit
    constrain attribute motion to 0

    though when the block is hit by another block the movement seems to be transferred or the weight of the other blocks causes the initial block to move.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Personally, I've never had any success when dealing with moveable objects trying to make them immovable in-game. Best of luck in trying to find a solution based on a single actor without spawning or replacing; I'll be interested if you do.

    For interest, why are you constraining motion to 0, and not using Change Attribute?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • carlosacj36carlosacj36 Member Posts: 54
    on touch rule, read the x and y value for actor.position attribute, and make a constrain attribute to that actor to this values. I never tested that, but i think that must run ok.
  • carlosacj36carlosacj36 Member Posts: 54
    i have a print screen for this rule, but i dont know how to post it
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    carlosacj36 said:
    on touch rule, read the x and y value for actor.position attribute, and make a constrain attribute to that actor to this values. I never tested that, but i think that must run ok.

    Yeah, basically what I wrote 4 posts up from yours except you don't need constrain, just change attributes.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • ShineyGamesShineyGames Member Posts: 157
    you could destroy the actor and spawn a unmovable actor in its place?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Good game; can I play?

    You could destroy the actor and spawn an unmovable actor in its place?

    ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.