moving a wall

dufdaviddufdavid Member Posts: 28
edited November -1 in Working with GS (Mac)
Hi, how to move an object in only one direction when an actor collides with it? (ex: move a square wall up when you collide with the bottom and keep that new position...one way movement).
Thanks,
David

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    I would use the interpolate behavior so the rule would be when actor overlaps or collides then

    Interpolate self.positionY to 120 ( 120 being the Y position you want the actor to end at) You can set an interval for the movement so its slides up or put it at zero and it will move instantly.
  • cbtcbt Member Posts: 644
    And with simo103's method you can uncheck the "movable" box inside an actor, under the physics section. This way you can get better performance.

    And you dont need to use "collide" behavior as well..
  • dufdaviddufdavid Member Posts: 28
    Thanks for your respond. What if i don't want the actor to move if it get touch from an other side than the bottom? (a square would move only when one of the 4 sides get touch by an other actor, otherwise it would not move)
    Thanks again,
    David
  • simo103simo103 Member, PRO Posts: 1,331
    You would need to create an Attribute for your moving actor and constrain is Y position + half its height to that attribute that would be its top side. Then when it collides with the wall you would need to compare that with the Y position of the wall - half its height and use that to determine if it was a hit at the bottom of the wall or elsewhere.

    Note: The X,Y position of an actor is its middle. Thus you need to add or take away half its height from/to its Y to get its bottom/top edge.
  • msonesmsones Inactive, Chef Emeritus Posts: 75
    Another easy way to do that, dufdavid, is to create a second (invisible, immovable) actor whose position is entirely constrained to just the bottom edge of the block, and create the interpolate rule on that actor. Constrain the position of the whole block to this new actor - that way, it will only move when it hits the new actor along the bottom edge, and both will move up in unison.
  • dufdaviddufdavid Member Posts: 28
    ok thanks @msones. I did it that way but i was looking for a way to avoid having 2 actors for the same. I tried to do it the way @simo103 told me to but I can't get it to work...guess I will stay with 2 actors....

    Thanks all!
    David
  • dufdaviddufdavid Member Posts: 28
    hum...if I create my actor immovable, it won't stop when it collide with an other actor. Suggestions?
    David
  • dufdaviddufdavid Member Posts: 28
    anyone?
  • simo103simo103 Member, PRO Posts: 1,331
    if did a quick template for you to play around with. Right now if you move the white box and hit the blue wall it won't do anything but if you hit from below the bottom it is turn green.

    See if you can pull what you need from that.

    http://www.resqwest.com/TEST/collide_bottom.gameproj.zip
  • dufdaviddufdavid Member Posts: 28
    ok thanks @simo103 but it's not working for what I need to do. I also need the wall to move again if the actor collide again and stop to move when it collide with an other wall (actor). If I use the immovable feature, it won't stop when it collide with an other actor.
    David
  • simo103simo103 Member, PRO Posts: 1,331
    hi David,

    I modified the same file and have it so that it moves if you bump the wall at the bottom, and will move again and again when touched until it collides with the second wall. (same download link).

    Hope that helps.
  • dufdaviddufdavid Member Posts: 28
    Yes thanks, that helped for one of my problems. Is there a way to make the blue wall bounce just a little bit when it reach the stopping point on the pink wall (to be able to stop just before that point so if the blue wall get push again it would move a little bit near the stopping point and pounce again)?
  • simo103simo103 Member, PRO Posts: 1,331
    you will need to try putting a little restitution in both walls to see the effect and adjust until it does what you want. 0 is off 1 is very bouncy so try in between those numbers.
  • dufdaviddufdavid Member Posts: 28
    Thanks @simo103! It's working! It's not very smooth but it does what I wanted. I will work around that.
    David
Sign In or Register to comment.