Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: diagonal line with collisiondetection  (Read 2828 times)

0 Members and 1 Guest are viewing this topic.

eniddelemaj

  • Newbie
  • *
  • Posts: 13
    • View Profile
diagonal line with collisiondetection
« on: October 06, 2016, 09:15:24 pm »
hey ,

i know how to use the getglobalbounds and intersects functions to simulate a collision
with to objects.an example would be pong. but it does only work
with straight sides not diagonal. as you know there is an invisible rectangle around the
entity and when its diagonal , there is too much space between the rectangle and the entity so
the hitbox is invalid.
now i want to make a collision detection which supports diagonal "hitboxes" too.
i looked for pixel collision detection but i read, that it isnt much effective.
are there any other ways to solve this? i didnt really found much on google about this.
thank you for your help:)

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: diagonal line with collisiondetection
« Reply #1 on: October 06, 2016, 09:54:04 pm »
Global/local bounds are only the smallest RECTANGLE that can hold the shape.

If you want to implement a well defined collision system you are looking for a physics library.
If easy to set up Box2D with SFML.

I would like a spanish/latin community...
Problems building for Android? Look here

TCVM

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: diagonal line with collisiondetection
« Reply #2 on: October 07, 2016, 06:00:27 am »
Box2d is way too powerful if you just need rotated rectangle collision, and no physics. The Seperating Axis Therom is what you are looking for. This is a good guide on how to implement it:http://www.dyn4j.org/2010/01/sat/

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: diagonal line with collisiondetection
« Reply #3 on: October 07, 2016, 03:10:30 pm »
Box2d is way too powerful if you just need rotated rectangle collision, and no physics.

Could be, but IMHO i find more practical learn to implement a well-known physics library that you can use in several projects than implementing an algorithm that only tells you if two shapes collides but no the point of impact and you need to debug your algorithm in severals test case before you can use it on real code to prevent odd/buggy behaviors.

Example of this: Several projects use Box2D to implement ray casting to render lights.
I would like a spanish/latin community...
Problems building for Android? Look here

eniddelemaj

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: diagonal line with collisiondetection
« Reply #4 on: October 07, 2016, 04:26:12 pm »
okay these information helped!:)
thank you very much guys