Moving actor without going off screen

MasterdonMasterdon Member Posts: 3
edited November -1 in Working with GS (Mac)
Hey folks,

My actor is only moving left, right when I'm touching it, the problem is if I move too fast from left or right the actor is going off screen. I would like to make it stop before he's going off screen.

I would like to know the rule to prevent the actor going to far on screen...

thank you.

Comments

  • dotsonj23dotsonj23 Member Posts: 316
    I assume you are using the "Move To". Just don't use it, it sucks and is really buggy. Instead use constrain. You could use constrain to constrain the actor between two coordinates and to follow your touch. If you must use "Move To" you could also put up invisible walls with collide with you actor turned on so the actor does not go past the walls. That is how I used to handle it before I realized constrain and interpolate worked better.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    dotsonj23 said:
    I assume you are using the "Move To". Just don't use it, it sucks and is really buggy. Instead use constrain. You could use constrain to constrain the actor between two coordinates and to follow your touch. If you must use "Move To" you could also put up invisible walls with collide with you actor turned on so the actor does not go past the walls. That is how I used to handle it before I realized constrain and interpolate worked better.

    Just so you know, interpolate does not work well with the physics system, neither does constrain (as in constrain to touch1 x and y). So if you need collisions to respond using the physics system you need to move, change velocity, accelerate, etc.
  • dotsonj23dotsonj23 Member Posts: 316
    Yeah, I don't use those when i need collisions. That's when I use invisible walls and move to etc.. to control. GS just needs to fix the move to behavior so we don't have to jimmy rig it..
  • MasterdonMasterdon Member Posts: 3
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    you could always put it in a rule

    when attribute player.position.x is > 0
    when player position.x is < 480

    put movement code here

    that should only allow the player to move when it's position is within 0 and 480.
  • MasterdonMasterdon Member Posts: 3
    thanks, it should work like this !
Sign In or Register to comment.