Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   proximity problems (http://www.alice.org/community/showthread.php?t=7188)

x08 09-06-2011 05:16 PM

proximity problems
 
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.

GameKid 09-14-2011 12:25 AM

That is quite strange.
Maybe you added the code in the wrong place. Try putting that code in an if/else statement in the movement method, and put the movement variables in the else section.
I hope this helps.


All times are GMT -5. The time now is 08:13 PM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.