Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
proximity problems
Junior Member
Status: Offline
Posts: 8
Join Date: Aug 2011
Location: Melbourne, Australia
Default proximity problems - 09-06-2011, 05: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);
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.
Reply With Quote
Senior Member
GameKid's Avatar
Status: Offline
Posts: 467
Join Date: May 2011
Location: My magnificent castle
Default 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.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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