Change direction when colliding with wall

axehammeredaxehammered Member Posts: 12
edited February 2012 in Working with GS (Mac)
Hello,
I'm having problems making my actor change direction when colliding with walls.

I have created an attribute called "movingright" and when set to 1 actor moves right and when 0 actor moves left.

I have also created two rules-
When movingright=1 and collide with wall change attribute movingright to 0
and
When movingright=0 and collide with wall change attribute movingright to 1

My actor begins by moving right and when it collides with the wall it changes direction and goes left as planned, but then when it collides with the wall on the other side it just continues to move left.
I have also tried to use different wall actors for left and right and this didn't work either. Am I missing something really simple?

Any help would be appreciated.

Comments

  • axehammeredaxehammered Member Posts: 12
    Thanks for the reply, I think the problem with that is that there are more than 2 walls on each scene and not always at the same X position on both sides.

    Is there any reason why the way I have tried to do it isn't working?
  • axehammeredaxehammered Member Posts: 12
    I've followed the above, and it doesn't seem to do anything. I've had to start with the actor moving to the right and when it hits the wall it just keeps on going to the right.

    Can you explain what the above should be doing?
  • axehammeredaxehammered Member Posts: 12
    Ive transfered everything in the template you have provided to my actor and it just doesn't work for me. Ive managed to get some movement, but it slows down and stops before it reached the right wall. I increased the linear velocity and it did reach the wall but it didnt change direction after touching it.

    It also seems to be effecting my actor jumping, so now it accelerates straight up out of the scene.

    Thanks for trying to help, any other suggestions would be greatly recieved!
  • axehammeredaxehammered Member Posts: 12
    Yeah that's the kind of thing I mean.
  • AppsterDudeAppsterDude Member Posts: 84
    Don't use an Integer Attribute use a Boolean.
Sign In or Register to comment.