How do I have multiples of one sprite have own rules

0 favourites
  • 13 posts
From the Asset Store
Footsteps SFX One contains 400 sounds of steps and jumps on different surfaces.
  • When I got my enemy ai working, I copy pasted the enemy sprite all over the layout and started playing. When I got to the first enemy, it shot a bullet but then every other enemy shot one when the player sprite wasn't even in the enemy range. How do I make it so that every multiple of the sprite had its own id/ai and know when to shoot?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Did you reference the correct enemy-sprite in the event?

  • Without looking at your capx I can guess you're using the system->compare condition with distance() expression to check the range. You can probably fix it by either using the system->"pick by comparison" condition to pick the objects in range or you could loop over the enemies with a "for each" condition.

  • Without looking at your capx I can guess you're using the system->compare condition with distance() expression to check the range. You can probably fix it by either using the system->"pick by comparison" condition to pick the objects in range or you could loop over the enemies with a "for each" condition.

    Indeed I am using that exact command to check the range of the player with a range variable. Can you please tell me how do I incorporate your suggestions into an event form? I also don't know how to showcase my catman.capx. The range check command I am using for my enemy is " (RangeVariable) is Greater or equal to distance(Gunman.X,Gunman.Y,Player.X,Player.Y) " and that is for one sprite. I want it so that only the enemy that has the player in range to attack.

  • add a second condition to that (for each (player/enemy)) so it checks which is active.

  • Asdasing There's a few ways you can do this.

    You can add a condition for "For each" along with your 'within range' condition. It'll check every single enemy separately to see if it is within range.

    Also, you can set an instance variable to an enemy UID and use that to compare.

  • Carbincopy

    Along with the range checking event, I have added the " System -> For each Gunman " and what it did is so that each copy (not clone) of the sprite only shoot if the player is within the range of EVERY enemy. This probably means that the condition is checking for every copy of the sprite to meet its condition and only then the action plays. The other method to check and compare the UID of every enemy sprite copy I do not know how to do. If you can explain it that would really help. Thanks otherwise.

  • LittleStain

    I am not using multiple sprites, I am using copies of one sprite. Suggest whether it is better to make many sprite enemies and put them in a family or my way. And then explain the method of referencing the correct sprite, because that could be useful later for my game. Thanks.

  • Asdasing Does this work for you?

    • Set up "For each" enemy
    • set instance for each enemy and put the distance in that. I think you originally set up distance to select all enemies rather than using the enemy object as a condition. This allows you to now use enemy as the condition and compare the instance (distance to player).

    https://dl.dropboxusercontent.com/u/73836006/enemyShoot.capx

  • System -> Every tick / Gunman Set Range to distance(Gunman.X,Gunman.Y,Player.X,Player.Y)

    LoopSystem -> For each Gunman

    Gunman -> Range Less than 250 / System Set group "Rapid Attack" Activated

    LoopSystem -> For each Gunman

    Gunman -> Range Greater or Equal than 250 / System Set group "Rapid Attack" Deactivated

    The result is still the same after I made my events for my enemy like this. Every enemy needs to have the player in range so that all of them attack. My game is also a platformer and not a top down shooter, however I definitely do have very nice ideas for a top down shooter after Catman

  • well.. you're doing things wrong here.

    first of all - use function to execute a behaviour (shooting).

    2nd of all - use trigger of some kind. (currently i'm not on my pc so i can't check) but LOS should be usefull here. "Has LOS to object"

    then you call function to shoot.

    activating / deactivating groups is just misused in this case.

    oh yeah, and you will need timer or your enemy will shoot indefinitely while in range. (unless you want that)

  • saiyadjin

    It actually works now. Thanks to your tip about using group deactivation wrong, I can now use this all the time. What I did is i made it so the shooting is controlled by a variable instead of event group control. Thank you so much.

    And thank you

    Carbincopy

    LittleStain

    R0J0hound

    for helping me with this as well

    Problem solved.

  • Glad to hear it. Fill free to link your finished game so we can see the end results. JC

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