Author Topic: collision detect one against other objects  (Read 1037 times)

Offline bili

  • byte
  • *
  • Posts: 39
    • View Profile
collision detect one against other objects
« on: July 05, 2012, 09:31:43 pm »
I just wonder on how to do collision for the following scenario. I got one main cube moving along the horizontal line and 5 other cubes moving along the vertical line at different position i.e. not in the same line. I want to test the collision between the main cube and other cubes so that if any other cube collides with the main cube, i will set it visibility to false.

How should I do this?

I already set collision mode for main cube to self and other cubes to others.

Thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12005
    • View Profile
    • http://www.jpct.net
Re: collision detect one against other objects
« Reply #1 on: July 05, 2012, 09:42:19 pm »
Just use one of the collision detection methods that fit. In case of a cube, the spherical approach might be sufficient. It won't be exact, because a sphere isn't a perfect approximation of a cube, but it should be good enough. Another way would be to detect the collisions yourself based on the cubes position. This is almost trivial if the cubes don't rotate and comes down to a few simple distance checks.

Offline bili

  • byte
  • *
  • Posts: 39
    • View Profile
Re: collision detect one against other objects
« Reply #2 on: July 07, 2012, 08:42:13 pm »
Thx it works.

I use a loop to check for collision between other cube and the main cube and set collided cube visibility to false.