[x][SOLVED]How to find out if A is on top of B node?
Posted: Fri May 01, 2009 10:34 pm
I'm trying to implement jumping in my game , but im a bit stuck while trying to find out if the player is on top of another object.
I've tried this:
But it isn't working...
Any ideas why it isn't working? I have done this in 2d ...but in 3d it seems to be totally different ...
I've tried this:
Code: Select all
inline bool isOnTopOfNode(ISceneNode* a, ISceneNode* b) //is a on top of b??
{
const vector3df& v0 = a->getPosition();
const vector3df& v1 = b->getPosition();
const vector3df& s0 = a->getScale();
const vector3df& s1 = b->getScale();
return
( //we have a good chance to skip a few instructions...
(v0.X >= v1.X) && (v0.X <= v1.X + s1.X) //x ?
&&(v0.Z >= v1.Z) && (v0.Z <= v1.Z + s1.Z) //z ?
&&(v0.Y <= v1.Y) && (v0.Y >= v1.Y + s1.Y) //y ? a on top of b?
);
}
Any ideas why it isn't working? I have done this in 2d ...but in 3d it seems to be totally different ...