Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Event disabling and re-enabling (http://www.alice.org/community/showthread.php?t=5109)

SirThorfinn 09-28-2010 04:28 PM

Event disabling and re-enabling
 
Lets say I have a FPS with working ammo counters and stuff but when the counter reaches 0 Alice automatically does the reload animation, during this i want certain events to disable until the animation is over so it doesn't mess with the guns orientation during the reload. (Example: I don't want the player to be able to aim down the sight while reloading)
Any tips?:D

Awesomeness 09-28-2010 06:09 PM

Make a variable that turns on/off whenever you start/stop reloading, and whenever someone say, tries to looks down the sight, make it check if you're reloading with an if else statement.

If you needer a deeper explanation let me know.

Dameria 09-28-2010 06:17 PM

You can make separate boolean variables for each action of your person. For example, lets say you have the ability to look down your sights, but you don't want people to be able to do it while reloading. Create a boolean variable called "isReloading" and keep it set it to default "False". Now in the event where you call upon the gun reloading, just put an if/else statement in the place of that method and put "if(isReloading), do nothing; else, person.aimDownSights". Now in the method where you are reloading, in the method itself before you do anything else, set "isReloading" to "True" in the beginning, and then when the animation finishes, set "isReloading" to "False" again. This way, when you go to reload, it will turn the boolean on, therefore disabling you from aiming down your sights, and as soon as the reloading ends and the boolean turns back to false, you can aim down your sights again. You can repeat this process with all of your other methods that you do not want to happen while reloading. Or you can create difference booleans so that, lets say you cannot reload while you are running, or look down your sights while you are running.

SirThorfinn 09-28-2010 07:10 PM

[QUOTE=Dameria;25886]You can make separate boolean variables for each action of your person. For example, lets say you have the ability to look down your sights, but you don't want people to be able to do it while reloading. Create a boolean variable called "isReloading" and keep it set it to default "False". Now in the event where you call upon the gun reloading, just put an if/else statement in the place of that method and put "if(isReloading), do nothing; else, person.aimDownSights". Now in the method where you are reloading, in the method itself before you do anything else, set "isReloading" to "True" in the beginning, and then when the animation finishes, set "isReloading" to "False" again. This way, when you go to reload, it will turn the boolean on, therefore disabling you from aiming down your sights, and as soon as the reloading ends and the boolean turns back to false, you can aim down your sights again. You can repeat this process with all of your other methods that you do not want to happen while reloading. Or you can create difference booleans so that, lets say you cannot reload while you are running, or look down your sights while you are running.[/QUOTE]

Thanks for the help it works perfectly:D:D


All times are GMT -5. The time now is 11:55 AM.

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