How do I set a variable as the number of object into LoS?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have the object Fire, witch has the internal variable Isolation

    I want to make isolation = the number of stones the fire is surrounded by

    So i created a line of sight for the fire, but i don't know how to proceed

    Any idea?

  • Easy way is to create an invisible object that pins to the Fire (make it the size you want for the detection radius) and then have Isolation as the number of stones being touched/overlapped by the invisible object. If it's any more complex than this then we'll need some more details on what the stones are..

  • Easy way is to create an invisible object that pins to the Fire (make it the size you want for the detection radius) and then have Isolation as the number of stones being touched/overlapped by the invisible object. If it's any more complex than this then we'll need some more details on what the stones are..

    Is that easy, i've already tried creating the invisible pinned object, but im stuck in the " have Isolation as the number of stones being touched/overlapped by the invisible object" part

  • (event) Pinned object "On Collision With" Stones

    (condition) For Each Stone > (action) Add 1 to Isolation

    To check if it's working correctly, create a text object and set text to (""&Isolation).

    This will display the Isolation variable so you can ensure it is calculating the correct number of stones.

  • It is working! but with some adjustments

    Condition:

    "Every 1 second" (to make it less CPU heavy)

    Pinned objects "is overlapping stone"

    For each Stone

    Fire "pick nearest to pinned object"

    Event:

    Fire -> add 1 to isolation

    in order to make it dynamic, i've added another event right after "every 1 second" (but before the isolation +1 addition): Fire -> set Isolation to 0

    The isolation every 1 sec is:

    reset to 0

    added +1 for each stone nearby

    so for example, if there are 2 stones nearby, the result is always 2, and if i add another stone, after 1 sec it's 3. If i remove all stones or move the fire away, it's 0!

    Now, every event involving the isolation variables must trigger 0.01 seconds after the "every 1 second" trigger, in order to let the game correctly calculate the isolation after the 0 reset.

    It works like a charm!

  • You actually could get rid of the "For each stone" and just go with "Set Isolation = Stone.PickedCount"

    This will return the actual number of instances which are overlapped by the pinned object.

    Btw, if you have a license you can use the container to get rid of the condition "Fire pick nearest pinned object" and directly referenced the "radius" object you use for detection.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You actually could get rid of the "For each stone" and just go with "Set Isolation = Stone.PickedCount"

    This will return the actual number of instances which are overlapped by the pinned object.

    Btw, if you have a license you can use the container to get rid of the condition "Fire pick nearest pinned object" and directly referenced the "radius" object you use for detection.

    Awesome suggestions!

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