How do I create NPC following other NPC with same sprite or family?

0 favourites
  • 6 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • case : i have one sprite with instance variable (name), when the sprite is create, this instance variable (name) can be change as : player, NPC1 or NPC 2

    so, the moving behavior is depend on what the "name" of the instance. If it create as "player" than it can be controlled, but when its as "NPC" or "NPC2" its move like an AI (NPC).

    game play : when every NPCs create, it must move on other "player" or "NPC", depend on the nearest object (player).

    As the Player with instance "NPC" : If the nearest object is Player ("player"), so it move on it, but if the nearest object is Player ("NPC2"), so it must move on to it.

    problem : how can this object sprite can triggering what object targetting move? since all abject is the same sprite with only have different instance variable?

    note : all player is only the copy of one sprite object!

    here is the event sheet :

  • You mentioned a family, but I don't see it on your screenshots.

    Add the sprite to a family, move the "name" variable to the family. Then you could pick one instance of the sprite and another instance of the family in the same event.

  • Hi, dop2000

    I don't use family in my screenshots, because with or without this doesn't make any differences.

    I used family for simplify event, prevent any repeating the same event.

    so, i use only one sprite and create the other copy with event since the move of the sprite is same.

    then how the "Sprite" with "name : NPC" can "see" the "copy of Sprite" with "name: NPC2" and the "copy of copy of Sprite" with "name: PLAYER" then chase to move on to the nearest of it?

  • then how the "Sprite" with "name : NPC" can "see" the "copy of Sprite" with "name: NPC2" and the "copy of copy of Sprite" with "name: PLAYER" then chase to move on to the nearest of it?

    Use a family!

    One instance of the sprite will see another instance of the family.

  • Hi dop2000

    thanks your suggestion, for to be clear, i must create another family with same instance but different variable that needed for any instances to "See" another.

    now its work!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • another family with same instance

    You mean with the same object.

    The variable "name" should be defined on the family. It will be available for family and object instances.

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