Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

4 "x" Positions - How to Move "x" to Position 3 if "x" is in Position 2?

Hi all!

I have tried searching for an answer within the forums but couldn't seem to find anyone who has the same dilemma as I have. My objective is relatively simple - I want to move an Actor from one X position to 3 other positions on "touch" so I created a 0 Alpha Right Hemisphere and a 0 Alpha Left Hemisphere on the Scene and did the following commands:

(Sorry, I can't figure out for the life of it how to attach imgur images on this forum!)

Below are my "x" integer attributes which are X Positions:
_Game.PanPosX1 = 162
Game.PanPosX2 = 310
Game.PanPosX3 = 480
Game.PanPosX4 = 570

also, Game.PanX is my actor's X_

**_RULE for moving to PanPosX2:
(When All conditions are valid) Actor receives event - touch - is pressed
Change Attribute > game.PanX to Game.PanPosX2_**

Code above will make my Actor move to Position 2, which is x=310. Works so far.

In order for you to get to position 2, you need to be in either position 1 or 3 and to move to position 4, you need to be in position 3; you can't jump more than one position but needs to be in ascending or descending sequence 1-2-3-4 position.

So my question is, can someone kindly help me make a code to move from position 2 to 3? The code I've used below (made sense in my head) doesn't work unfortunately:

RULE for moving to PanPosX3:
_(When All Conditions are valid) If Attribute game.PanX = game.PanPosX2
Actor receives event - touch - is pressed
Change Attribute > game.PanX to Game.PanPosX3_

When I enable the 2nd code above, Actor just moves straight to PanPosX3 and skips PanPosX2 completely. Please help. Thank you!


  • Two.ETwo.E Posts: 491Member, BASIC


    This might help. All your conditions are being met, so I added in an extra condition that seems to help.

    Let me know if you need anything explain or questions.


  • vincentfelixvincentfelix Posts: 2Member

    Thank you. I've come up with a slightly working code since my post and this is working as follows with one issue (which I'll mention below):

    On Rule:
    When ALL Conditions are valid:
    Actor receives event - touch - is pressed,
    Change Attribute Pan.X to game.PanX+145
    and to move left, it is game.Panx-145

    big issue obviously is I can't stop them from going to far left or too far right; is there any code I can stop them from going out of the x-positions 145, 290, 435 and 580?

  • vmfelixvmfelix Posts: 1Member, BASIC

    Hi this is me vincentfelix as well (this is my subscribed account).

    I've solved the problem just for everyone out there who is encountering the same issue. Here's my solution and an addition to my code above:

    On Rule:
    When ALL Conditions are valid:
    Actor receives event - touch - is pressed
    Attribute game.PanX - is equal to or less than 580,
    Change Attribute Pan.X to game.PanX+145

    Hope that will help someone in the future too. I know it's a simple code but I have zero coding skills haha!

Sign In or Register to comment.