GameSalad

Howdy, Stranger!

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

How to make actor stay in the boundaries of the white line?

Hello! I have this project & I want you to move within the boundaries of the white line & if you collide with the black part the game will end. How would I do this?
Image and video hosting by TinyPic

Comments

  • http_gamesaladhttp_gamesalad Posts: 1,340Member
    edited December 2014

    I don't want you to be able to do this Image and video hosting by TinyPic

  • SocksSocks London, UK.Posts: 12,822Member

    Why do I get the feeling if I answer this one the question will just keep expanding to include more and more requirements ? Lol :smile:

    Ok, here goes, I'm going to presume the red square is controlled by the keyboard direction arrows (nothing about how the actor is controlled is mentioned so that part is obviously not important) . . . Ok, make an actor, uncheck 'moveable' place two copies of it into your scene and size and position them to occupy the black areas, add a collide behaviour to this actor and set it to collide with the red square.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @socks if possible I would like something to constrain to the white lines on the left & right side which if the red object hits either of the walls it won't move. The red actor is controlled by move left & right when the corresponding keys are pressed. The white actors are spawned every 0 seconds then destroyed once it's out of the screen. The white lines also change position. Does this information help you more?

  • SocksSocks London, UK.Posts: 12,822Member

    @Socks said:
    Why do I get the feeling if I answer this one the question will just keep expanding to include more and more requirements ? Lol :smile:

    . . . . right one cue . . . lol :smile:

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @socks could you stop with your sarcasm.. & just tell me exactly what information you need to help me with this issue?

  • SocksSocks London, UK.Posts: 12,822Member
    edited December 2014

    @http_gamesalad said:
    socks could you stop with your sarcasm.. & just tell me exactly what information you need to help me with this issue?

    Mmmmm . . . let's think about it, spend Christmas Eve working on someone else's project for free, in my own time, after they've told me off - knowing that the question will change and evolve and expand because they can't be bothered to write out a detailed question to start with, and knowing that this person takes the help given to him without so much as feeling the need to even thank people . . . .

    . . . .or I sit around and do what I want ? Hmmmm . . . difficult choice [hand slowly reaches for another fist of peanuts] but I'm going to go with option 2 ! lol :)

    Merry Christmas . . . and hopefully someone with more patience will be willing to give you their time.

    Best of luck sorting this out.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member
    edited December 2014

    @socks I just sat down & explained it if you had the > @Socks said: >patience

    to read it. > @http_gamesalad said:

    socks if possible I would like something to constrain to the white lines on the left & right side which if the red object hits either of the walls it won't move. The red actor is controlled by move left & right when the corresponding keys are pressed. The white actors are spawned every 0 seconds then destroyed once it's out of the screen. The white lines also change position. Does this information help you more?

    Then instead of telling me it wasn't as detailed or you needed more information, pictures, & or the game template its self you just said something extremely sarcastic (which I found uttermost insulting & clearly wasn't needed nor humorous)

    & again instead of just saying what you needed you decided to waste your time & mine writing

    @Socks said:
    Mmmmm . . . let's think about it, spend Christmas Eve working on someone else's project for free, in my own time, after they've told me off - knowing that the question will change and evolve and expand because they can't be bothered to write out a detailed question to start with, and knowing that this person takes the help given to him without so much as feeling the need to even thank people . . . .

    . . . .or I sit around and do what I want ? Hmmmm . . . difficult choice, but I'm going to go with option 2 ! lol :)

    Merry Christmas . . . and hopefully someone with more patience will be willing to give you their time.

    Best of luck sorting this out.

    I come on the forums for help, not sarcasm.
    btw, I'm very thankful for the help I receive. I'v thanked you on numerous occasions for the help you've given me (also gave you some free awesome as gratitude) so the ludicrous statement of > @Socks said: and knowing that this person takes the help given to him without so much as feeling the need to even thank people . . . .> is pure & utter nonsense.

  • BBEnkBBEnk Posts: 1,764Member
    edited December 2014

    create a real attribute and call it whiteLine.X or whatever, then use a constrain attribute in the white line and constrain its self position.x to the whiteLine.X attribute.

    Now in your red actor put a constrain attribute in there and constrain it's X position to max(game.whiteLine.X-AAA,min(game.whiteLine.X+CCC,self.Position.X))

    now AAA will be how far you want to limit left movement

    and CCC will be the Right limit.

    So if white line was 200px wide and Red actor is 50px wide it would look like this.

    and you can move white line anywhere on scene and actor will always be constrained within.

  • SocksSocks London, UK.Posts: 12,822Member
    edited December 2014

    ...

  • http_gamesaladhttp_gamesalad Posts: 1,340Member
    edited December 2014

    @BBEnk i don't think that'll be the best fit because the white lines change directions randomly. I want something on both sides of the wall so that the red object can't get out of the white lines. Is this possible? if you need the game template it's self I'll be glad to inbox it to you or post it on here. Thanks so much for the help. Marry Christmas :)

  • zweg25zweg25 Posts: 738Member
    edited December 2014

    @The_Gamesalad_Guru said:
    This was amusing.

    lol

    @Socks already explained how to do it with colliders..

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @zweg25‌ would you mind explaning it in more detail because I don't believe what he said would work because the white lines move around the screen & the white lines are spawned every 0 seconds . Unless you know a more efficient way of having a constant spawn! Thanks :)

  • BBEnkBBEnk Posts: 1,764Member

    @http_gamesalad said:
    BBEnk i don't think that'll be the best fit because the white lines change directions randomly. I want something on both sides of the wall so that the red object can't get out of the white lines. Is this possible? Image and video hosting by TinyPic I took a screen shot.. if you need the game template it's self I'll be glad to inbox it to you or post it on here. Thanks so much for the help. Marry Christmas :)

    what I said could still work but you would have to track width and height of White lines and track position of Red square. BUT easier way would be what @Socks‌ said. Just have the White lines spawn a blocker wall on left and right side of themselves.

    Now I'm going to assume your moving the White lines down so you will have to constrain the blocker walls X value and make them non rotatable because you can't set them non-moveable.

    So If it were me the way I would accomplish this is I would make the White lines and blockers non-moveable, and make the scene tall like 10000 or so, and then move the camera up leap frogging the White lines via tracking the cameras position this gives the illusion of movement, and when the camera reaches say 9000 set it all back -8000 that way it would be endless, and everything can be set to non-moveable,it's a bit of work but works very well I build all my endless game types like this.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @BBEnk‌ thanks! I'll give it a try :)

  • BBEnkBBEnk Posts: 1,764Member

    @http_gamesalad‌

    Thinking about this a better way would be to have a white background and place black blocks might be less work.

    If you place the white lines and spawn the blockers your going to have to account for overlap. For instance were the corners meet.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @BBEnk‌ so I should have a white background & have black blocks spawning?

  • BBEnkBBEnk Posts: 1,764Member

    @http_gamesalad said:
    BBEnk‌ so I should have a white background & have black blocks spawning?

    I think that might be easier because they would be your boundaries. So basically you could have a black block on the left that spawns/moves a black block to it's right a certain distance to create the path.

    You could setup a few attributes that would track X,Y and length,width and the blocks would feed to that in order so the path would build. Sort of like a Flappy Bird Pipes.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @bbenk as I thought it what @socks suggested didn't work . I put the two walls (lime green) on both sides turned on collide & unchecked movable. I'm not able to follow the white lines because of the green walls. Image and video hosting by TinyPic unless I mis understood what @socks said.

  • BBEnkBBEnk Posts: 1,764Member

    @http_gamesalad said:
    bbenk as I thought it what socks suggested didn't work . I put the two walls (lime green) on both sides turned on collide & unchecked movable. I'm not able to follow the white lines because of the green walls. Image and video hosting by TinyPic unless I mis understood what socks said.

    No what he's saying is have each white line spawn it's own blocker.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    @bbenk OOOHHHHHH face palm lol! Would you mind explaining that one more time for me please? :) I didn't understand how @socks explained it & that's why I told him it wouldn't work out of my confusion! my @socks lol :/. I'm still getting the hang of things so please bare with me :)

  • BBEnkBBEnk Posts: 1,764Member
    edited December 2014

    @http_gamesalad‌

    heres a simple way of doing it, should get you going.

  • http_gamesaladhttp_gamesalad Posts: 1,340Member
    edited December 2014

    @bbenk Hello! Sorry for the bother again! I have looked at your template & I'm still just a bit confused.. I don't understand how you got those blockers to spawn to stop the red object from leaving the white line! What I tried to do is game.random x (which by the way determines where the new position of the white lines) is to make a blocker with the same exact rules as my line white lines with the same game.random x but I tried to do +100 so it lays right on the outskirts of the white lines forming the blockers you made in the template. But for some reason it doesn't want to spawn game.random x plus the addition 100 pixels & told it to do. It would make sense to me to say game.random x +100 doesn't that make sense to you?

    Image and video hosting by TinyPic

    This is what I have set up in my spawner to spawn the white lines. I'm trying to do the same exact thing for my blockers but the +100 & it's not working. Thanks :)

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    Hope you understand what I said & hope I didn't confuse you

  • http_gamesaladhttp_gamesalad Posts: 1,340Member
    edited December 2014

    @bbenk you can see when I tell them to spawn +100 it does something weird
    Image and video hosting by TinyPic
    It's very close to what your template has.. but is there another way of spawning the wall blockers?

  • http_gamesaladhttp_gamesalad Posts: 1,340Member

    bump?

Sign In or Register to comment.