Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Need help with mummy kill method! (http://www.alice.org/community/showthread.php?t=4883)

Disembodied Loaf 08-17-2010 04:56 PM

Need help with mummy kill method!
 
I'm trying to create a method in which a knight swings his sword and it kills a mummy. I've got the swinging part and the "die" method down, but I can't get the "if the sword touches the mummy, call the die method" part down.

What I did at the end of my swing method was an if statement. That's what I can't figure out.

It needs to be: if sword touches mummy: mummy.Die().

I tried: if (sword.isCloseTo(0 meters, mummy))
{
mummy.Die();
}

It didn't work.

jediaction 08-17-2010 05:14 PM

Well, Alice does not have the capability to detect "is touching" but there is an "is within". Any questions?

DensetsuNoKaboom 08-23-2010 07:11 AM

You want the sword to detect collision if it's within, say, 1 meter of the enemy, rather than 0, because 0 means that at that exact moment, the sword's center must be in the same exact place as the enemy's. Experiment with that "within" distance, and see what works.


You might also want to put that same If/Else statement all throughout the method, rather than at the very end.

labtek9 08-25-2010 09:00 PM

I don't know about you guys but the if statement dosen't like me too much, it never works so I use while.

jediaction 08-27-2010 09:30 AM

Hmm. Are you using it wrong?

labtek9 08-30-2010 02:07 PM

probably

DensetsuNoKaboom 08-30-2010 07:03 PM

If I can have a look at your code, I can probably help.


All times are GMT -5. The time now is 03:42 AM.

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