SFML community forums

Help => General => Topic started by: stavsen on March 01, 2018, 04:39:02 pm

Title: Collision detection of a transformed entity
Post by: stavsen on March 01, 2018, 04:39:02 pm
Hi,
I've been reading the code from the SFML Game Development book (https://github.com/SFML/SFML-Game-Development-Book/blob/master/03_World/Source/Aircraft.cpp)
and i have a small question regarding collision detection with the Node system.

If i have an Entity that inherits from SpriteNode, and the Entity has been transformed in some way
does sfml have any built in functions to check whether something is colliding with the sprite of the Entity?

(Usually i would just get the sprits bounds and then use the Rect class functions to check for collisions, but i obviously cant do that with the system showed in the book, as the sprites own transform isn't related to where its being drawn on the screen anymore :\ )

Or would i need something like a physics library for this?

Thanks :)

Title: Re: Collision detection of a transformed entity
Post by: eXpl0it3r on March 03, 2018, 11:02:39 am
If you want to do simple AABB you just need to apply the whole tree transformation to get the sprites bounding box.
Title: Re: Collision detection of a transformed entity
Post by: Hapax on March 06, 2018, 10:25:18 pm
If the sprites are rotated, you might want to consider using this: Rectangular Boundary Collision (https://en.sfml-dev.org/forums/index.php?topic=22241.0)