proximity problems -
09-06-2011, 04:16 PM
Dear All,
Am working on an assignment for uni, so please do not give a super-direct answer - but please offer some advice if you can.
Have a model, player controlled and a tree. I need to make the model not able to pass through the tree.
I currently have >>
if ((tree.isInFrontOf(model) && (tree.distanceToFrontOf(model) < 2)) && ((tree.distanceToLeftOf(model) < 0.5) || (tree.distanceToRightOf(model) < 0.5))
{
model.say(debug line);
}
else
{
model.move(forward, 0.5);
}
*ADDED* the distanceToLeft/Right were added to add in a minimum proximity radius to the tree when passing it.
But for some reason this is not working correctly at all. I've tried switching model and tree in the if statement. I've tried playing with the parameters, and also tried a simple kangaroo.distanceTo(tree)..... none of them are detecting the way I would expect. The tree is about twice the height of the kangaroo.
I also have the same issue with a goal object. It's not correctly detecting the distanceTo player and NPC.
Is this a bug in 2.0, or am I doing something seriously wrong? Help, please.
|