dop2000's Forum Posts

  • Is the function on the same event sheet? If it's on a different event sheet, you need to Include this event sheet.

    If this doesn't help, could you share your capx?

  • You can use Browser.Log -> Array.AsJSON to get the correctly formatted JSON string. All you need to change is to double all quotation marks.

  • Try this:

    Array Load from JSON   
    Copy/paste this string:
    "{""c2array"":true,""size"":[10,2,1],""data"":[[[60],[150]],[[60],[265]],[[60],[380]],[[0],[0]],[[0],[0]],[[0],[0]],[[0],[0]],[[0],[0]],[[0],[0]],[[0],[0]]]}"
    
    [/code:2ecaytek]
  • I'm trying to reply to a post and keep getting "SORRY YOU HAVE BEEN BLOCKED" error.

    Here is my comment:

    After many attempts and edits the forum finally allowed me to post it.

  • There are many issues with your code..

    If enemy is not in range or has no LOS, all highlighted events are executed on every tick. This is clearly wrong.

    Also, you need to pick the correct enemy instance in your function, otherwise you are assigning isSearching=true for all enemies.

    "Wait 5 seconds" inside an event which is triggered on every tick also makes little sense.

    I would add a Timer behavior to enemy and do this:

    Enemy NOT overlapping NoticeRange   Function call "StartSearch" (parameter: Enemy.UID)
    and Enemy isSearching=false        
    
    Enemy NOT has LOS to Player   Function call "StartSearch"  (parameter: Enemy.UID)
    and Enemy isSearching=false        
    
    On function "StartSearch"
      Enemy pick by Unique ID = Function.Param(0)
         Enemy set isSearhing=true
         Enemy start timer "StopSearch" for 5 seconds (once)
         Enemy start timer "SearchForPlayer" for 0.3 seconds (recurring)
    
    Enemy On Timer "SearchForPlayer"
        For each Enemy   // as Timer may be triggered for several enemies at the same moment
              ............... find path etc.
    
    Enemy On Timer "StopSearch"
       Enemy set isSearching=false
       Enemy stop timer "SearchPlayer" 
    [/code:1j18ux2j]
  • Sorry, I still don't understand your question.

    You need to populate this array? Should these locations be predefined on each level? Or are they generated on random?

    If predefined, you can read them from a file, say, using CSV plugin.

  • So do you still have the second problem with "Trigger once"? If you do, please share a screenshot of your events.

  • You can try adding Platform behavior to the box, disable standard controls.

    Enable collisions for your Player sprite.

    Then do something like this:

    It works, but requires some tweaking.

    You can slow down both the player and box, disable any animation changes while the box is being pushed etc.

  • Here is a very primitive example, works with rectangular shapes with Origin point set to (0,0) :

    SmallSprite Compare X if less than BigSprite.x  -> SmallSprite Set x to BigSprite.x
    Compare two values -> SmallSprite.BBoxRight>BigSprite.BBoxRight  -> SmallSprite Set x to (BigSprite.BBoxRight-SmallSprite.width)[/code:2snzegm8]
    (similar code for Y coordinate)
    
    If your sprites have complex shapes, there are several things you can do.
    If partial overlapping is ok, you can save SmallSprite position in instance variables oldX and oldY on every tick. If on next tick the sprite moves and no longer overlaps the BigSprite, return its position to oldX, oldY.
    
    Or you can pin a few very small invisible sprites to the corners of the SmallSprite, lets call them detectors. If any of the detectors is not overlapping the BigSprite, return SmallSprite to its previous position. 
    Or you can use the same principle with image points and "Pick overlapping point" event.
  • newt

    Wow, didn't think of that! Great idea, I'm going to use it in my game too.

  • This code should work if ANY instance has boolean set:

    x----------------------------------x
    |Sprite -> Is boolean b set        |  do something
    |System- > Trigger once while true |
    x----------------------------------x[/code:1mpcjwqr]
    
    And it will only be triggered once. If after that you set boolean to other instances, it will not be triggered again.
    If you reset b to false for all instances, and then set one to true, it will be triggered again.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No worries!

    I just realized that the blue CarCollision sprite is not necessary in the last example. You can replace it with Car in all events, then delete.

  • Christmas

    Ok, an improved version, should work as you described:

    https://www.dropbox.com/s/0ctlui86sbd4l ... .capx?dl=0

  • Glad it helped!

  • I fixed it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/34dycek87zrwi ... .capx?dl=0