Not able to instantiate an AABB object

Hey!
I'm new to using Box2D and C++ in general.

I'm trying to detect the body which was click on.
I've read that I need to do a world AABB query. But I'm not able to create an b2AABB object properly for this.

b2AABB aabb;
aabb.lowerBound = b2Vec2(1,0);

Gives me the error
error: ‘aabb’ does not name a type
aabb.lowerBound = b2Vec2(1,0);


Any help would be appreciated.
Thanks.
Hi, did you put these lines in a block like main() ? or in the global space ? because this error happends when you put some function call in the global space.
I mean maybe you've done something like this :

Code: Select all

#include ....

b2AABB aabb;
aabb.lowerBound = b2Vec2(1,0);

int main()
{...}

when it should be something like this :

Code: Select all

#include ....

b2AABB aabb;

int main()
{
     aabb.lowerBound = b2Vec2(1,0);
}


Nigel

Original thread: https://box2d.org/forum/viewtopic.php?t=10020