Search Unity

Edge Detection in 3D

Discussion in 'Scripting' started by abhi_shekv, Aug 13, 2009.

  1. abhi_shekv

    abhi_shekv

    Joined:
    Mar 20, 2009
    Posts:
    10
    Hi Guys,

    Just wanted an idea as to how we can implement edge detection in a game. Something like Assassin's Creed where the character holds on to the edge of a wall or something thereby hanging. Any pointers? One way I thought of doing it is through a raycast of detecting if something is there in the vicinity or not and if not, then we can assume that we are standing at the edge.

    Looking forward to your inputs.

    Regards.
     
  2. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,647
    triggers. complex as heck for assassin's creed tho...
     
  3. abhi_shekv

    abhi_shekv

    Joined:
    Mar 20, 2009
    Posts:
    10
    But will it not be too complex for putting them on every edge? Leave alone AC but even for a normal small game wouldn't it be too much?
     
  4. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,647
    afaik for something like ac, that's how you'd do it. but then they had 140 people working on it (yeah not a real number). for a pc game, no not too complex. just a heck of a lot of work. could get to be too much for an iphone game tho. in which case you'd probably want to make your levels fairly linear. give em a couple places to make choices but limit it.
     
  5. Jim Offerman

    Jim Offerman

    Joined:
    Jul 17, 2009
    Posts:
    177
    In Tomb Raider this is done using "markup", which is just another form of triggers that tell Lara where she can hang on ledges, jump on poles, etc. All that markup is carefully placed by hand, which is a monster of a job.

    Having said that, putting stuff in to make your game aware of ledges and other obstacles is only one part of the job. The other part (the really tough one) is implementing all jumping and hanging behaviors in your character controller.
     
  6. Maker16

    Maker16

    Joined:
    Mar 4, 2009
    Posts:
    779
    You might just work out an editor script where that detects edges on a model and places triggers on them. It would be somewhat complex, but the pay off is that, once you have it, you can process any building model through it, saving you development time down the road.
     
  7. iphonefreak

    iphonefreak

    Joined:
    Feb 25, 2009
    Posts:
    157
    I wound recommend creating some meta data that describes what the character can and cannot hold onto that is separate from the actual level geometry. Also you should probably pre-calculate such information as doing lots of ray casts during the main game loop will be slow.

    Another way could be to have a collision mesh that is a very low polygon version of your level. Then in that mesh you can mark certain polygons as different types of collision. So for example you could mark edges in that collision mesh. Performing collision detection on the low poly collision mesh is far quicker than doing so on your level geometry.
     
  8. abhi_shekv

    abhi_shekv

    Joined:
    Mar 20, 2009
    Posts:
    10
    Well I have no other choice than to go the hard way for time reasons. So I am doing it through raycasts. Lets see how it goes. Will let you know on any progress. Thanks for the help guys. Unity forums rock :) !!!