Reloading a Weapon
craps
Member Posts: 353
I have finally worked out a working "swipe" function to throw an object.
After the actor is thrown how do I get another actor to appear and ready to go?
I would also like to limit the number of actors to be thrown.
Any help?
After the actor is thrown how do I get another actor to appear and ready to go?
I would also like to limit the number of actors to be thrown.
Any help?
Comments
The only way I can think of doing this is by having a boolean game attribute, (game.ReadyToReloadActor) for example, and setting up a rule within the actor that will be thrown stating that whenever the "swipe" function occurs, change game.ReadyToReloadActor to "true". Next you will need to set up another rule somewhere else in the same scene stating that if game.ReadyToReloadActor is true, then spawn the appropriate actor at the appropriate X and Y position relative to the scene. After the actor has been spawned to the correct position, change game.ReadyToReloadActor back to false so the actor can be reloaded multiple times.
As far as limiting the number of actors to be thrown, this can be done by adding an integer game attribute (game.NumberThrown), and adding to the second rule mentioned above stating that if game.numberThrown is less than X, where X is the number of throws allowed, then, as mentioned in the second rule listed, spawn the appropriate actor to the appropriate X and Y position.
Hope this helps...and let me know if you have any more questions.
I was a real pain to change around. I never was able to rebuild the function by myself.
Instead I adapted my app to it.
I really did not understand a lot of how it worked but was able to change enough to make it work for me by playing with many of the variables and rules.
Still have not figured out how to keep the object being thrown from being pulled off the bottom of the screen.
Thanks the reload worked great. But it only reloads once. Will I have to make a rule with +1 somehow like making a life bar so it will reload multiple times?
It sort of works - if you click/touch the actor to be thrown it will continually spawn another actor - over and over again. But, if you thrown the actor it will only spawn one actor.
Then made a rule that when the mouse/touch was clicked change attribute back to false - this did not work.
game attribute (integer 4)-numberThrown.
Rule - swipe/ mouse down
Attribute-numberThrown<4
then
Spawn actor
But of course it continues to spawn.
Change Attribute game.numberThrown to game.numberThrown + 1
Give this a try and let me know how it works.