I'm trying to get simple movement with collision detection going. From my reading, i found that simply changing the object's position with orxObject_SetPosition may mess with the physics engine (and thus, with collision detection, which has to be very accurate for the type of game I'm making). I noticed that orxPhysics has its own SetPosition, but I can't figure out how to get an orxPHYSICS_BODY pointer. Also, will that screw things up too?
I don't want to have physics applied to the player, I just want movement and collision detection.
Comments
(EDIT: So yes, meant to say, this will get the object moving towards the right of the screen, &c.)
You could also make your objects Solid, which would make them stop once they hit such a barrier.
Or, of course, you could just poll your objects for their position every frame in your update() call.
Basically, there are several options
A small precision: calling SetPosition directly on physics objects wouldn't have worked either as it breaks the contacts tracked by Box2D everytime you do that. Also if you need to access any structure stored on an orxOBJECT, you need to use the helper macro orxOBJECT_GET_STRUCTURE(), in this case it'd be orxOBJECT_GET_STRUCTURE(MyObject, BODY).
That doesn't work since it returns a orxBODY instead of a orxPHYSICS_BODY but then maybe i don't know what I'm talking about. I'm new to both C++ and orx. I'm trying to use orxPhysics_ApplyImpulse to get my spaceship moving but first of all I can't get a orxPHYSICS_BODY to put into it and second I have no idea if this is a good thing to do at all.
//AlgoJerViA
And of course this doesn't work at all (it compiles but nothing happens to the spaceship), probably mostly because I have no idea about what I'm doing with the vectors and if the typecasting is OK to do.
//AlgoJerViA
And you want to use orxBody_ApplyImpulse and not orxPhysics_ApplyImpulse. The whole orxPhysics API is mostly used internally only and everything has been wrapped in the orxBody or even orxObject modules.
As sonicbhoc said, it's much better to open a new thread and I just saw yours so I'm going to reply to it shortly.