A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Collision detection - but kinda hard!

  1. #1
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747

    Exclamation

    Hi all, i have looked around the forum before posting this question and none of the code snippets i have found seem to do the trick.

    I am designing a game in a 3d isometric environment, the character (under keyboard controls) can move around, the problem being at the moment it can walk straight over the walls and objects in the area! Most of the sollutions for 2d side-scrollers dont work because of the view point, any suggestions?

  2. #2
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747
    Ok, thought i had better make this a little clearer! the walls are at angles (obviously) so the mc shape is a square even though that isnt the shape of the wall. If my character goes anywhere in this square it stops as if it had hit the wall even though its no where near! Any ideas?

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    314
    I'm guessing that you're using hitTest for collision detection. That generally won't work in a 3D world (isometric or otherwise) because hitTest only deals with the two dimensions of the stage. So while a character may be nowhere near a wall in three dimensional space, his image may be drawn on the stage overlapping the wall and therefore hitTest would return "true".

    My suggestion is to forget about hitTest (it's processor intensive anyway and will slow down your game if you need to check too many movie clips). Instead, set up a two dimensional array and use it to keep track of the contents of each tile (or square). Then when the character (or anything else) attempts to move into a particular tile, check the array to see what's in that tile.

    For instance, suppose the array set up is called "tile[x][y]". And suppose there's a wall that runs through the 5th square of the 4th row. You could store "wall" in tile[5][4]. Then, when the character tries to enter the 5th square of the 4th row, your script would check tile[5][4] and see that there's a wall there. And based on that, it wouldn't let the character move there.

    I hope that's clear and it helps. If it's not clear, but you think it would help, let me know and I'll try to write a quick fla to illustrate.

    Good luck!

  4. #4
    Senior Member random10122's Avatar
    Join Date
    Mar 2002
    Location
    Sheffield, UK
    Posts
    1,747
    That would be great if i could do that! So the .fla would be a big help. Im new to making games in flash (this is my first), i previously made websites and had no use for arrays therefore i am not familiar with how they work. An example would set me straight :-)

    Cheers,

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Posts
    314
    Okay, I'll make an fla and post a link to it here later this evening.

  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    314
    I've made the fla, and it's heavily commetted so hopefully it will be easy to follow.

    Unfortunately, I just realized that I'm temporarily unable to upload to my website. But if you email me at froth@frothworks.com, I'll send you the fla (I'm going out for awhile right now, but I'll check back later tonight).

  7. #7
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Froth
    This is the same area I am currently struggling with. Is there any chance you can either post the fla or email it to me as well. Sounds like a great help to those of us new to iso worlds. Thanks.

    Scott
    (Australia)

    smayer1972@yahoo.com

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