bounding box for a triangle...

evertevert Member Posts: 266
edited November 2014 in Working with GS (Mac)

Hi all,

I'm working on a game and i'm having the same problems as everyone else...
I need a bounding box around my triangle but now its a square it needs to be a triangle.
anyone any idea's?

now it is like the left one, i needs to be like the right one.

thanks

Comments

  • ArmellineArmelline Member, PRO Posts: 5,422
    edited November 2014

    You can get an accurate triangle collision by overlapping several rectangles and triggering a collision only when all are touched (i.e. the overlapped area is touched but not the excluded areas). Getting a non-equilateral triangle is trickier but still possible.

    Of course, if you want an equilateral triangle you can just rotate a square and use a corner.

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

    @Armelline said:
    You can get an accurate triangle collision by overlapping several rectangles . . .

    Surely you'd only need three ?

  • jsorr2jsorr2 Member Posts: 279

    Or you could make 100 1x1 pixel actors spaced evenly to form one single triangle

    :smiley:

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

    @evert said:
    I need a bounding box around my triangle . .

    Example file.

    Link: https://www.mediafire.com/?kbtez6qcdj0tlxy

  • ArmellineArmelline Member, PRO Posts: 5,422
    edited November 2014

    @Socks said:
    Surely you'd only need three ?

    Three is several :P I was thinking of a different method to you, though.

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

    @Armelline said:
    Three is several . . .

    Yep, I suppose it is ! For some reason I also think of several as more than a few but less than a lot. :p It's got too much of the word 'seven' in it for my liking.

  • evertevert Member Posts: 266

    thanks! @socks i did it a bit different but still the same result!

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

    @evert said:
    thanks! socks i did it a bit different but still the same result!

    No problem.

    With the method above in my demo you can set it up so that one actor spawns the three edge actors, so you just have to drag a single triangle actor into your scene wherever you like and the sides are automatically generated for you . . . this would be useful if you had to drag lots of triangles into a scene.

Sign In or Register to comment.