Hello everyone!
I was trying to set up a simple character controller and I needed to check wether if a given rigidbody was grounded or not. I’m using this code snippet (got it from one of the examples)
[code]
MemoryBuffer contacts(eventData[P_CONTACTS].GetBuffer());
while (!contacts.IsEof()) {
Vector3 contactPosition = contacts.ReadVector3();
Vector3 contactNormal = contacts.ReadVector3();
float contactDistance = contacts.ReadFloat();
float contactImpulse = contacts.ReadFloat();
// If contact is below node center and mostly vertical, assume it's a ground contact
if (contactPosition.y_ < (node_->GetPosition().y_ + 1.0f)) {
float level = Abs(contactNormal.y_);
if (level > 0.75)
onGround = true;
}
} [/code]
The compiler, though, keeps complaining about P_CONTACTS not being declared even though I’m including the same headers as the example (I know I don’t need many of those but I just tried to make sure before asking):
#include <iostream>
#include "MemoryBuffer.h"
#include "Context.h"
#include "PhysicsEvents.h"
#include "PhysicsWorld.h"
#include "Scene.h"
#include "SceneEvents.h"
#include "PhysicsEvents.h"
A grep through the source reveals that this P_CONTACTS constant is being used in PhysicsWorld.cpp and PhysicsEvents.h, but I couldn’t find any declaration in either of them.
How can I solve this? Where is this variable declared and why does the example work but not my code?