Alice Community  

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

Reply
 
Thread Tools Display Modes
Any way to "disable" methods?
Old
Deidara1BG
Member
 
Deidara1BG's Avatar
 
Status: Offline
Posts: 34
Join Date: Jul 2011
Location: Bulgaria
Default Any way to "disable" methods? - 07-20-2011, 06:11 PM

Hello community!

In my FPS,you click the enemys to kill them.Is there any way i can make something like this?

While the mouse is clicked on *enemy*, stop/disable *method*

OR

While the mouse is clicked on *enemy*,do *method*

(in the *method* in the second example there would be either a falling or a dissapearing animation,and then the "disable" thing (if its even possible!).

In other words,my question is is there a way to stop a method while in game,or using another method.If it was for an animation it would be way easier,but i cant predict when the player will shoot the enemy,or if the player will even shoot it...


Yeah,thats my cat on the avatar.

If you like gaming,check out my youtube channel.(Deidara1BG)
I post different videos of gaming there,im going to start posting Alice videos soon,aswell as some commentaries.

If you say "Plz" because it's shorter than "Please" i will say "No" because it's shorter than "Yes".
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 07-20-2011, 06:32 PM

Use a boolean variable, have it set as true when the world starts and use an IF/else statement saying if that is true it will run that method, but once the character clicks the object/enemy, have that variable turn to false to stop the method


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
Nighthawk0973
Senior Member
 
Nighthawk0973's Avatar
 
Status: Offline
Posts: 240
Join Date: May 2011
Location: In front of my computer.
Default 07-20-2011, 08:09 PM

If your clueless on what he just said than do this:

(For the sake of this mini-tutorial, lets pretend we're creating an enemy death method, and making it so that the method can only be called once)

First create a new variable by visiting the world properties tab and clicking 'Create new Variable'.

Set it's type to boolean (True/False) and it's name to EnemyAlive, make it's value set to 'True'.

Now in the methods tab create a new method and name it 'EnemyDeath' now your code for the method should be set to the following.

(sorry if this looks more like Java than alice, that's because I'm using pure text)
Code:
If EnemyAlive == true {
This will test if the boolean variable we created is equal to true.
Code:
//EnemyDeathCodeGoesHere
Set EnemyAlive == False
What we're doing here is initiating the enemy death code, disabiling his AI, and making him perform a death animation. Next we set the value of EnemyAlive to false, so that this method cannot be repeated more than once.
Code:
}Else{

}
Now we finish things off by closing the If and opening the 'Else', as you can see, there is no code in the Else, so we simply close the else.

That's all of the method! What this does in a quick runthrough is simply. We have a variable that states our enemy is alive. Once he is shot we call on a method that makes him die. Inside this method we test a condition: if the EnemyAlive variable is true, than kill the enemy and set this variable to false, and then end the method. When we shoot the enemy again, it does the same method again but this time, since we set 'EnemyAlive' to false it skips the 'If' part (therefore not repeating the death animation) and begin the 'Else' part, which does nothing and than simply ends the method.

This is our methods code all in one:
Code:
If EnemyAlive == True{
//Enemy Die and Disable AI
Set EnemyAlive = False
}Else{

}
That's the complicated version of simple! Hope you enjoyed!
   
Reply With Quote
Old
Deidara1BG
Member
 
Deidara1BG's Avatar
 
Status: Offline
Posts: 34
Join Date: Jul 2011
Location: Bulgaria
Default 07-21-2011, 08:15 AM

Oh,i see.Thanks,now it is more clear to me.Gonna try it,thanks!


Yeah,thats my cat on the avatar.

If you like gaming,check out my youtube channel.(Deidara1BG)
I post different videos of gaming there,im going to start posting Alice videos soon,aswell as some commentaries.

If you say "Plz" because it's shorter than "Please" i will say "No" because it's shorter than "Yes".
   
Reply With Quote
Old
7yrold4Alice
Guest
 
Status:
Posts: n/a
Default 08-08-2011, 05:27 PM

I had that problem too!
   
Reply With Quote
Old
puzzlemenow
Junior Member
 
Status: Offline
Posts: 2
Join Date: May 2012
Location: canada
Default 05-21-2012, 03:55 PM

can u make a video tutorial on this?

if so thanks alot
   
Reply With Quote
Reply

Tags
i am horrible with alice, stop a method

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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.