Access Specific Family Member Instance Variables

0 favourites
  • 2 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • <img src="" border="0" />

    Brief summary:

    NPCTalk is a global variable set at 0 default.

    Talk1, Talk2, Talk3 are family instance variables that contain the text said NPC is to speak.

    TalkNum is a family instance variable that contains how many times the NPC is to talk.

    The idea is, player presses action key to talk to NPC.

    NPC talks and NPCTalk = 1

    If player presses another key, either:

    1) Stop talking if NPC TalkNum is 1

    2) Continue talking if NPC TalkNum is 2.

    It works until Keyboard->On any key pressed

    *-> If NPCs Talk Num = 1 then blah

    *-> Else -> Trigger Once then type Talk2.

    The NPC I'm trying to talk to has TalkNum set to 2 and is meant to talk twice. But he isn't. It will talk once and is definitely breaking into the If NPCs Talk Num = 1 branch. It never goes into the Else. Its not accessing the proper NPC family member that has TalkNum set to 2.

    Any solution for this? Am I missing something? I clearly have it so NPCs is being accessed by collision. It should only be referencing the NPC with TalkNum set to 2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Answered my own question.

    Turns out that I needed to add Wait 1.0 second commands inbetween every NPCTalk add 1 event. What was happening was when you hit a key, it would execute everything at the same time, cascading down the events. I sometimes forget that these events execute in fractions of a second, and no one presses/releases keys that fast.

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