Help with snap to actor

sawkasteesawkastee Member Posts: 184
edited February 2013 in Working with GS (Mac)
Hello I am trying to get an actor to snap to another actor when it touches. It snaps but jitters alot and disappears.

Here are my rules. First 2 rules are in the actor that is moveable. Final rule is in the actor that is the target box.

image

image

image

Comments

  • JarrenHJarrenH Member Posts: 206
    I think the problem is that your constrain to touch, and interpolate to target rules are interfering with each other. You see, even though the movable actor has changed it's position, and it appears as if it is no longer being touched, the system still registers it as a touch until you remove your finger or release the mouse. Simple solution would be coded like this:

    When actor overlaps or collides with target
    Interpolate to target
    Otherwise
    When actor receives touch
    Constrain to touch

    Not at a computer to check at this exact moment, but seems to make sense in my head.
  • sawkasteesawkastee Member Posts: 184
    @JarrenH yeap that worked great for the snapping. minor problem now i can't get the actor to interpolate it's size back down to it's original width/height. I was using interpolate when touched to have the actor grow and shrink when touch is pressed and not pressed.

    Rule
    when actor receives touch pressed change attribute touch_press =1
    otherwise touch_press =0

    RUle
    actor overlaps, collides with target hit box actor
    interpole self position x & y to game.target hitbox x&y
    otherwise rule nested
    Rule attribute touch_press =1
    self size width height 148 x 116
    constrain attribute self position x& y to mouse position x & Y

    Rule
    attribute touch press = 0
    interpolate self size width hieight 128 x96
Sign In or Register to comment.