How Do I Create Special Powers For A Character?

FallingBoxStudiosFallingBoxStudios Freelance Graphic DesignerMember Posts: 822
Hi, I would like to know how to add special powers to a character,
basically my character walks automatically in the game but if you hold the screen (Use a special power) your character can stop moving, but how do I make you able to use the powers without accidentally using more then one power at a time, maybe this will help you understand.

Heres how i have set the rules for the first power:
Create attribute - Boolean - set to false

Rule: actor receives event - if mouse button is down.
Change Attribute: Boolean - to - true.
Destroy - Actor. (so it does not look like you still have that power)

Heres how I have set the second power:
Rule: actor receives event - if mouse button is down + attribute (boolean) is true.
Destroy - Actor.

The only problem is that the second the first power is used the other one gets used 1 second afterwards, how do I make it that if 1 power is in use you can't use the second power? and how do I add more then 2 powers (I can't figure it out yet) Thanks

Hunter.

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Do you have more than 1 different power? Or do you have 1 power that you want to be able to use multiple times, but with a delay? Does you character start with a small number of the same power, and you want it to count down each time one is used, but not all of them in one go?

    What is the power? What does it do? If you can say that without giving any game secrets away, it might make it easier to understand what you want.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    Let's say you've got three different power buttons on the screen always, and you only want to use one of them at one time. On each power button have something like this:

    Rule: If Touched Is Released And game.Power Recently Used = False
    [USE POWER]
    Change Attribute: game.Power Recently Used = True
    Timer: After 3 Seconds
    Change Attribute: game.Power Recently Used = False

    Replace 3 in the timer with the delay you want before the next one can be used

    Every one would have the same code, but where I've got [USE POWER] is where you'd put the power code for that specific button/power

    This will work on one power button, for the same power too.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross Thanks, I'm gonna try that now, but where is the attribute game.Power Recently Used?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    @KevinCross Thanks, I'm gonna try that now, but where is the attribute game.Power Recently Used?
    It's an attribute that you would have to add in/create. Choose whatever name you want, I just chose one that was descriptive for the example. It needs to be a game attribute though and not one on an actor.

  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross but the power does not really exist, the power is triggered by touching the screen, so the power button does not trigger the power, it just tells you how much you have got, but when you touch the screen it takes away 2 powers when its supposed to take 1
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Wherever you're taking away 1, replace the code with the above. That's where the rule needs to go.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross It worked great! It only did 1, but the other ones don't disappear even after 3 seconds.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Are you saying you can't use the other ones, and that the touch no longer activates after 3 seconds?

    Do you understand the code I gave above? Just reading it from the screen can you see and understand what it's doing?
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross yeah i understand it, heres what i placed

    Rule: If mouse button Is Released + game.Power - is - False
    Destroy: actor
    Change Attribute: game.Power Recently Used = True
    Timer: After 3 Seconds
    Change Attribute: game.Power Recently Used = False
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross Heres the image of what I'm doing - http://i.imgur.com/SJ8YjwV.png
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    The actor you're destroying has these rules on? Are you respawning the actor again?

    If "Destroy: actor" is definitely the correct thing you want to do then try putting it on the end

    Rule: If mouse button Is Released + game.Power - is - False
    ..Change Attribute: game.Power Recently Used = True
    ..Timer: After 3 Seconds
    ....Change Attribute: game.Power Recently Used = False
    ..Destroy: actor

    The dots show how things are nested in the behavours.

    I imagine the timer won't activate after 3 seconds once it's destroyed though.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross i tried that and it did the exact same thing but only after 3 seconds
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross do you think its smarter to change its image to a transparent blank image rather then destroying it, will that help?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I'm afraid I don't understand what the power does, why you're destroying the actor and what you're doing after it's destroyed i.e. respawning a new one. Without looking at your file I'm not going to be able to help any further.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    @KevinCross do you think its smarter to change its image to a transparent blank image rather then destroying it, will that help?
    I was going to suggest making it transparent by self.Color.Alpha = 0 and then making it self.Color.Alpha = 1 after the 3 seconds.

    Rule: If mouse button Is Released + game.Power Recently Used - is - False
    ..Change Attribute: self.Color.Alpha = 0
    ..Change Attribute: game.Power Recently Used = True
    ..Timer: After 3 Seconds
    ....Change Attribute: game.Power Recently Used = False
    ....Change Attribute: self.Color.Alpha = 1

    If you want it to fade out rather than disappear completely you could use Interpolate.
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross Basically its not really a power, its the only movement you have, by pressing the screen you use one of your powers (the power makes your character stop moving, because the game is kinda like a spy game, so your character walks automatically, but to not get caught by anyone you have to stop moving by using the power,) the power actor just displays how much you have, so I have set 3 versions of the power actor in a row with the same rules for all of them:

    Rule: If mouse button Is Down + game.Power - is - false.
    .Change image: to a transparent image.
    .Change Attribute: game.Power - to - true.
    ..Timer: After 3 Seconds,
    ..Change Attribute: game.Power - to - false.

    so when you hold the screen (use a power) one of the 3 power actors disappears, leaving you with 2 powers, then if you hold the screen again (use a power) you're left with 1 power left, if you don't understand do you want me to send you the project file?
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I'm at work at the moment (which is why I'm on the forum) but if you don't get to fix it before I'm home then send it later and I will look at this evening (it's 11AM in the UK at the moment so it won't be until 7 or 8 hours time.

    I'll PM you my email address
  • FallingBoxStudiosFallingBoxStudios Freelance Graphic Designer Member Posts: 822
    @KevinCross Thanks man, I managed to edit it slightly and it worked! thank you so much!
  • KevinCrossKevinCross London, UKMember Posts: 1,894
Sign In or Register to comment.