How to Identify Objects Distinctively

0 favourites
  • 6 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I have two different Sprites called “Blue_Unit” and “Red_Unit”. Where the “Blue_Unit” has two Behaviors; Pathfinding and LineOfSight, one Instance Variable called “Selected” of Type Number, and two Animations "Selected" and "Unselected". The “Red_Unit” has no Behaviors, no Instance Variables, and two Animations caleed "Seen" and "Unseen".

    The problem that I am having is when a “Blue_Unit” is Selected AND has Line of Sight (LOS) to “Red-Unit” I want to change the animation of the “Red_Unit” to “Seen”.

    That is I want to indicate to the player, that the currently selected “Blue_Unit” that has LOS to the “Red_Unit”, that the “Red_Unit” is seen by the selected “Blue_Unit”.

    The next following images attached below illustrate a simple setup of the scenario being described above.

    The idea that has been described at the beginning of this discussion Forum and illustrated by the preceding images works perfectly fine if and only if there exists one instance of “Blue_Unit” on the layout. Once this idea gets extended to multiple instances this approach no longer works.

    The result is quite simple I have one unit (call it “A”) and multiple instances of it (copies of the unit “A”). Also I have multiple copies of another unit (call it “B”). When I select one unit “A” out of the many copies of itself AND unit “A” has LOS to unit “B” change the animation of unit “B” to what I specify.

    Note that if unit “A” is selected but does not have LOS to unit “B” do not change the animation.

    With that I have stated my problem and what is the result that I want. I hope to hear from you guys suggestions, comments, and possible a practical solution to this problem.

    Thank-you for reading this thread.

  • Instead of events 12 and 13 try these:

    12
    On every tick -> Red set animation "Unseen"
    
    13
    Blue Selected=1
    Blue has LOS to Red -> Red set animation "Seen"
    
  • Yes this approach will not work. If just one blue unit cannot see a particular red unit then it will be set to unseen. The fix for this could be something like always set red_unit to unseen, and keep the event for if blue unit has line of sight then set to seen.

  • Thank you for your help and clarification. Here are the results illustrated by the next following images below. The idea that dop2000 proposed works. Now the problem with this idea is its usability.

    By usability, meaning that if we were to extend this idea to designing a unit combat system a new problem will arise. To discuss this problem I will first describe the new changes made to the project.

    The “Blue_Unit” now has an additional Behaviour; Turret and the “Red_Unit” has a new Instance Variable called “Targetted” of Type Number. A new Sprite has been added called “Bullet” with a single Behavior Bullet. The following image below illustrates the new game scenario setup.

    Now this problem is similar as to that problem first discussed in this thread, which was how to have a single unit that is selected AND has LOS to a specific object, have that specific object change its animation.

    The problem is of course unit combat system design. What I want to be able to do is,

    If a “Blue_Unit” is NOT moving AND has LOS to “Red_Unit”

    THEN

    Set the value of the “Red_Unit” Targeted to 1 AND add this “Red_Unit” as target.

    If a “Blue_Unit” is moving OR (has NOT LOS to “Red_Unit” AND “Blue_Unit” is NOT moving)

    THEN

    Set the value of the “Red_Unit” Targeted to 1 AND this “Red_Unit” as target.

    If “Blue_Unit” is Shooting

    THEN

    Spawn a Bullet

    The following image below illustrates a simple example of this combat system.

    Currently with this, nothing happens that is the “Blue_Unit” does not Spawn a Bullet. Overall why am I asking this and what I am getting arises from this story where I have had tried a more complicated variation of this combat system.

    Initially I had a family (Units_A) where this family contained,

    “Blue_Unit_0”, “Blue_Unit_1”, “Blue_Unit_2”, … “Blue_Unit_n” , where n is a positive integer.

    “Red_Unit_0”, “Red_Unit_1”, “Red_Unit_2”, … “Red_Unit_n” , where n is a positive integer.

    And so on with different colors and numbers.

    This family (Units_A) would contain the following instance variables,

    Unit_ID of type Number

    Health of type Number

    Damage of type Number

    And so on with different instance variables that could be change for each individual unit in this family.

    This family (Units_A) would contain the following behaviors,

    Pathfinding, LineOfSight, Turret

    Moving the desired units given a set of player restrictions on the screen was easy to setup as the conditions were simple. Once a combat system was required to be implemented this is where problems arise. The main problem was family member identification.

    With family member identification the problem is how do you know if for example “Blue_Unit_0” has LOS to a current “Red_Unit_1” and not to another units relating to its family. The solution for this may be quite simple that is create a copy of that family call is Units_B.

    To follow along what I am describing follow the following link attached below to a game that I am currently designing where there is an attached Template of the game.

    construct.net/en/free-online-games/lifetime-human-war-4211/play

    But creating another copy of the original family presents again a similar problem of unit identification. In some cases this idea works but in this thread not. I have followed these discussion forums links to which are attached below.

    construct.net/en/tutorials/understanding-picking-respect-333

    construct.net/en/forum/construct-2/how-do-i-18/recognizing-individuals-47138

    These threads and discussion discuss issues similar to this thread which brought me to nowhere. As such the next thing I tried is what I am doing now that is create a skeleton structure which will take on future assigned values. That is replacing the function of family with one sprite. Here I am trying to get a simple combat system of units to work between one another.

    Again thank you for reading this thread and any future help.

  • I must admit, I didn't have time to read and fully understand your message. But I suggest you move events 15 and 16 inside the "For each Blue_Unit" loop.

    Check out this demo:

    howtoconstructdemos.com/how-to-limit-the-angle-of-view-for-turret-behavior

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello again and sorry for the long reply. The demo that dop2000 sent works just need disable the Behavior of the Turret Rotate that is,

    Followed by this is the code of what to use and how and what not to do in order for things to work.

    Next is an image of how things looks.

    Next I have a question regarding the selection of target. See the highlighted code where the condition is,

    On Right Clicked "Red_Unit"

    THEN

    Set the value Targetted of the "Red_Unit" to 1 (which is True and 0 is False) AND Find a Path to the "Red_Unit".

    By Find a Path to the "Red_Unit" in this case what I am trying to implement is find the location of the "Red_Unit" and compute a distance away from the targetted "Red_Unit".

    An easier illustration of problem trying to be solved is visually described as follows,

    Where the green box around the "Red_Unit" indicates the distance away from the "Red_Unit" at which the "Blue_Unit", if "Blue_Unit" is Selected AND Right Button Clicked "Red_Unit", must stop moving towards the "Red_Unit".

    Thank you for reading and sorry for the long reply. A possible solution to this problem would be very much appreciated.

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