A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [HELP] Obstacles in the middle of the scene...

  1. #1
    Junior Member
    Join Date
    Jan 2005
    Posts
    11

    [HELP] Obstacles in the middle of the scene...

    I have a character that you can move up, down, left, and right from a view looking down on the character. Making him not leave the scene was easy. Now though, I am trying to put a square obstacle in the middle of the scene, that the character can not walk on. I'm missing something simple that I can't put my hands on.

    For the walls, when you hit the wall, it sets your x coordinate back outside, so you can still run along the walls but not go out. With this square, you can't use that same method. It doesn't know if you're running from the left, right, or bottom, or sometimes two of these. If you tell it to move you to the left of the obstacle, it only works correctly if you run into it from the left. If you hit it from the bottom, it jumps you over to the left of it.

    Is there any simple way to make it so that a character cannot walk in a certain area in the middle of the screen?

  2. #2
    Member
    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    93
    trye se uf you not hittets like this would be in youre character:
    if(!_root.oObstacles.hitTest(this._x,this._y,true) ){
    //and here you can you can go in direction like movespeed
    dont know if you wannt it that way but.

  3. #3
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    don't bother with the x or y's:

    your mc --> <--

    --> use this patern for moving: ._x += Speed_Of_My_

    if(hitTest bla bla bla) {Speed_Of_My_ = 0} else {Speed_Of_My_ = 5}
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  4. #4
    Junior Member
    Join Date
    Jan 2005
    Posts
    11
    Quote Originally Posted by artlink
    don't bother with the x or y's:

    your mc --> <--

    --> use this patern for moving: ._x += Speed_Of_My_

    if(hitTest bla bla bla) {Speed_Of_My_ = 0} else {Speed_Of_My_ = 5}
    But if you hit the obstacle from the left and you set your speed to 0, theny ou can move up or down against it... or away from it in that case.

  5. #5
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,650
    Sometimes you can't move, that's why I don't set the speed to 0, I instead push the player 1-2 pixels back. (tiny bump effect)

  6. #6
    Junior Member
    Join Date
    Jan 2005
    Posts
    11
    Quote Originally Posted by Ironclaw
    Sometimes you can't move, that's why I don't set the speed to 0, I instead push the player 1-2 pixels back. (tiny bump effect)
    I tried that first. But again, it doesn't know which side it's hitting it from. If you hit it from the left, it pushes you back a few pixels to the left. If you hit it from the right, it warps you over to the left.

  7. #7
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    Quote Originally Posted by InuxMedia
    But if you hit the obstacle from the left and you set your speed to 0, theny ou can move up or down against it... or away from it in that case.
    true.

    then just set a leftspeed, right speed,...

    They are plenty of ways to do the same stuff in flash, just choose your weapon
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  8. #8
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Dont you just love irony, my younger cousin was asking me how to do this yesterday so I still have the file!

    Anyways, have a look at what I did, pretty simple.

    Enjoy
    Last edited by Osteel; 05-01-2009 at 02:38 AM.

  9. #9
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    here it is.

    Then probably just need a function for multiple colision detection and that's it.

    Here you don't get the "bumping" effect as in ostel example even if it could probably be fixed in his example as well, and I dunno what I did ostel but while going on the top right wall I found myself into the wall actually.

    yeah I escaped it

    Probably just some rough version.
    Attached Files Attached Files
    Last edited by artlink; 02-02-2006 at 03:01 PM.
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center