Very unfair bug in classic

This forum is currently in read-only mode.
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • Step 1:

    Create an sprite and give any behaviour that allows movement (for example, platform behaviour)

    Step 2:

    Create an sprite for an enemy, with some particulary easy to see animation, for example, an arrow.

    Step 3:

    Insert this code

    "if enemy.x > player.x {set enemy.angle=180;} else { set enemy.angle=0;}"

    Step 4:

    In the layout, Ctrl+MouseLeftButton to make a copy of various enemies.

    then run the cap and observe that not all the enemies turn around, some of them wait until tle player moves his X to the greates or lowest position. So, some of them turn around some of the other doesn´t....nosense.

    This makes coding an enemy AI really difficult.

    But you can make this works by inserting "for each enemy" condition, however this only works in this case, when you have private variables and the number of the sprites is big, you cannot use "for each" condition, for other reasons, because its not supose to work like that....so there is no way to clearly separate the behaviour of several enemies of the same object

  • How about overlap at offset?

  • You can just check this in another post of mine, there is a cap in which you can see how it works.

    Overlaping at offset its for collisions, Im talking about private variables bugs

  • Not sure, as I am not a user of classic, but maybe there is no picking involved in the expression you are writing (ennemy.x will be the x of one ennemy, probably the first created), the for each actually force it to do this work for each ennemy individually.

    But if you have a way of do a simple picking event, that would work from my understanding.

  • Thats how picking works.

    If you want all the enemies to turn use either a global variable, or a function.

  • I´m not sure why my game is not working properly then...just one enemy, does exactly what it has to, if I added more enemies they get odd

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe this will work.

    1.) go to enemy character

    2.) go to "pick by comparison"

    3.) insert distance formula into pick by comparison

    value 1: distance( enemy.X, enemy.Y, player.X, player.Y)

    comparison: whatever you choose

    value 2: whatever you choose

    4.) create sub event under first event

    5.) go to enemy character

    6.) "compare x position"

    comparison: greater than Set angle to 180

    x coordinate: player.x

    7.) set angle to 180

    8.) create another sub event

    go to enemy

    go to compare x position

    comparison: less than Set angle to 0

    x coordinate: player.X

    9.) set angle to 0

  • Yes that´s work, but would you mind to chek the post "EnemyAI" and see what is happening there when you have free time? By pressing SPACE you can spawn more enemies. Spend a few minutes lookig how one enemy behave, because that´s perfect behaviour and then observe 4 spawned enemies...that is exactly what I say

  • Code should look like this

    event 1: enemy:Pick by distance(enemy.X, enemy.Y, player.X, player.Y)

    sub event 2: enemy: x greater than player x ----------------------------------- set angle to 180

    sub event 3: enemy: x less than player x -------------------------------------- set angle to 0

  • Works

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