Help, Why doesn't my variable and logic work?

0 favourites
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • Hello, I created a variable called EnnemisSpeed to which I gave as logic each time the player's bullet hits an enemy, it accelerates the enemy's speed, I created a global variable. I don't understand why this doesn't work? I forgot something in the settings???? Thank you in advance for your valuable help.

    dropbox.com/s/dqtks8w5v5kl7mp/FunShooter%20%2822%29.c3p

  • Maybe you need to increase the maximum speed to accommodate the speed increase.

  • Thanks for your help, it's nice to help me, I thought about that too but I don't think it's because if I increase the speed, I'll automatically go faster but I would like to go faster but with the way my logic works, please, I go in circles, I look for it but I don't understand why my variable doesn't work???

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello, I created a variable called EnnemisSpeed to which I gave as logic each time the player's bullet hits an enemy, it accelerates the enemy's speed, I created a global variable. I don't understand why this doesn't work? I forgot something in the settings???? Thank you in advance for your valuable help.

    https://www.dropbox.com/s/dqtks8w5v5kl7mp/FunShooter%20%2822%29.c3p?dl=0

    On Event 21

    I didn't see how you set the New Speed to the Enemies 8direction MaxSpeed at the moment you just increase the Global Variable "EnnemisSpeed" by 100 or at least I couldn't see it if you do so.

    So it should at least look like this:

    Bullet_Hero On Collision with Enemies:

    set enemies Max Speed to: Self.8Direction.MaxSpeed+100

    You don't need a Global Variable if the speed increase is per Single Enemy

  • Hello, the behavior I enabled by default is patchfinder, I would like to increase the speed of patchfinder and not 8 direction, I'm sorry if I'm confused, And I want to attribute to the enemy family group

  • Hello, the behavior I enabled by default is patchfinder, I would like to increase the speed of patchfinder and not 8 direction, I'm sorry if I'm confused, And I want to attribute to the enemy family group

    Is the same thing

    Bullet_Hero On Collision with FamilyEnemies:

    set FamilyEnemies PathFinder Max Speed to: Self.Pathfinding.MaxSpeed+100

    This Will increase the speed of the PathFinder for just the FamilyEnemy that Collide with the Bullet

  • Thank you very much for helping me and solving my problem, so I will delete my variable, I looked at an example and there is a variable, I was convinced that one was needed, thanks to you now I know that there is not always a need for a variable.

  • Thank you very much for helping me and solving my problem, so I will delete my variable, I looked at an example and there is a variable, I was convinced that one was needed, thanks to you now I know that there is not always a need for a variable.

    No Problem mate Glad it helped you

    Yeah is not always necessary the Variables its all depends on the situation.

    But even if you ever need to use Variables for something Else here is a few things to keep in mind:

    Global Variables:

    Are not linked to any Object, doesn't matter how much you change the Global Variables it will not affect any object unless you link the Object with the "Global Variable"

    Example:

    Set "Global Variable" to 100 <<<<< This by itself it will not affect any object or anything on the Game

    But if you do instead

    Set "Global Variable" to 100

    SubEvent: Pick Enemy (Your Enemy): Action Set Enemy "Health" to "Global Variable"

    This will set the Enemy Health to 100 or whichever Value that holds the "Global Variable" on that Moment

    ==========================================

    But there is a better option if you need to do something similar to what we did above they called "Instance Variable"

    "Instance Variable" are linked to the Objects you just need to Pick the right object and modify the Variables

    Example:

    We add an instances Variable "Health" to the FamilyEnemy

    Bullet On Collision with FamilyEnemy: Subtract 100 From "Health"

    You see here automatically c2 knows to which enemy has to subtract 100 from Health as the enemy was picked on the Collision

    But instead, if we do

    Create "Global Variable = Health"

    Bullet On Collision with FamilyEnemy: Subtract 100 From "Global Variable = Health"

    This will not do anything as we just modified the Global Variable but there was no object or anything linked to it

    So in resume for this type of Actions is better to use "Instance Variable" as they are linked to each object

  • I'm sorry to disturb, I did as it seems you told me, maybe it's not like that but I did as it seems to me to have understood and it doesn't work, I shoot the enemy, I kill a lot of enemies but their speeds don't increase at all not even a little bit, I sincerely hope that maybe with the updated link you can see what's wrong? I despair, I need a lot of help.

    dropbox.com/s/e96d83r8xy4pbhn/FunShooter%20%2822%29.c3p

  • I'm sorry to disturb, I did as it seems you told me, maybe it's not like that but I did as it seems to me to have understood and it doesn't work, I shoot the enemy, I kill a lot of enemies but their speeds don't increase at all not even a little bit, I sincerely hope that maybe with the updated link you can see what's wrong? I despair, I need a lot of help.

    https://www.dropbox.com/s/e96d83r8xy4pbhn/FunShooter%20%2822%29.c3p?dl=0

    On bullet hit enemy

    Are you trying to increase speed to just the enemy that has been hit by the bullet?

    or

    Increase the speed to Every Enemy?

  • Oh yes I forgot to specify, I am sincerely sorry by my lack of precision, I want to give the speed that increase to all enemies, that every time the speed increases it increases to all enemies, I am sorry, I should have specified it. In fact, I want every time I kill an enemy, the speed increases for each enemy

  • Oh yes I forgot to specify, I am sincerely sorry by my lack of precision, I want to give the speed that increase to all enemies, that every time the speed increases it increases to all enemies, I am sorry, I should have specified it. In fact, I want every time I kill an enemy, the speed increases for each enemy

    No Problem

    That changes everything then, you were correct using a Global Variable:

    Add a Global Variable = EnemySpeed

    Bullet On Hit FamilyEnemy: Action: Add 100 to (Global Variable = EnemySpeed)

    SubEvent: System >>> Pick All "FamilyEnemy": Action set PathFinder MaxSpeed to (Global Variable = EnemySpeed)

    =========================

    Also Every time you Spawn an Enemy as you do on your Event 47

    add an extra action after you create the object set FamilyEnemy PathFinder MaxSpeed to (Global Variable = EnemySpeed)

    ==================

    All of This is assuming that all the Enemies have the same Speed

  • I would like an enemy to die every timeI'm a little confused, I'm sorry. I have trouble because I don't speak English, I use a translator and it doesn't always translate properly

  • I have trouble because I don't speak English, I use a translator and it doesn't always translate properly

  • the variable, in systeme, I have to compare the value?????

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)