dop2000's Forum Posts

  • OK, thanks, the code on line 2 you posted, which condition are you using?

    "System Is Within Angle", it's a similar condition to "Is between angles"

    And what do you mean with (36-loopindex)? Do I need to add that literally to the action as: Set animation frame to: (36-loopindex)

    Yes, but I don't know if this will be a correct expression in your case.

    Oh and, is this code for 36 frames or 360? I'm trying to understand why you use 5 degrees, and use multiply loopindex by 10.

    It's for 36 frames. I loop in 10 degrees intervals from 0 to 350 degrees - 0, 10, 20, 30 etc. And for each interval checking if car angle is within 5 degrees of it. For example, for loopindex=8 it will check if car angle is between 75 and 85 degrees.

    .

    If your animation has 360 frames, then you can simply set frame to moving angle value. But you will need to convert it to positive number:

    Set frame to (Car.MoveTo.MovingAngle+360)%360

  • Move "Set angle" action from event #10 to #11

  • You can do it in a loop. For example, if you need to check in 10 degrees intervals:

    Repeat 36 times
     Car.MoveTo.MovingAngle within 5 degrees of (loopindex*10)
     	Car set frame to loopindex
    	Stop loop
    

    I don't quite understand how the animation is made in your case, so you might have to set the frame to something like (36-loopindex).

  • Check out "3D castle maze" template added in the latest beta.

  • Well, you can clear browser cache and storage. I meant you can't delete save slot from events.

  • No, it's not possible.

  • Try this:

    v1>50
    OR 
    v2>100 Deactivate group
    
    Else
    v1<50 Activate group
    
  • It works without "array" key, then the path will be just "0.3"

    But make sure there are commas between sub-arrays in JSON:

    [

    ["111","112","113","114"] , <- comma

    ["121","122","123","124"] , <- comma

    ["131","132","133","134"]]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would not recommend using dot in the key name.

    Also, it's easier to put JSON string into a variable, then you won't have to deal with escaping all quotation marks:

    String variable j={"key": "foo"}
    
    On start of layout 
     JSON Parse j
    

    Yes, I'm doing this as part of iterating through a foreach-loop.

    You need to post your project file or at least a screenshot of the full event sheet. When you show just one or two events, it's not possible to guess what might be wrong in the rest of your code.

  • If your JSON format is this:

    {"array": [["111","112","113","114"], ["121","122","123","124"], ["131","132","133","134"]]}

    you can access each value that you need using these expressions:

    JSON.get("array.0.3") - will return 114

    JSON.get("array.1.3") - will return 124

    JSON.get("array.2.3") - will return 134

  • Have you tried oosyrag's version? It's pretty cool.

    Here is with LOS raycasting:

    dropbox.com/s/djkilpaho46uuch/BorderAim.c3p

  • > If the events are at root level, they are executed on every tick.

    Why are they excluded?

    "Executed", not "excluded". Because that's how Construct works. All events are executed on every tick, unless they are triggers or functions.

    It's all local, so nothing is fetched remotely. All I'm doing is loading in a local JSON file that is embedded with the project.

    It still may require 1-2 ticks to be fetched, or maybe even longer on a slower machine. So you should not start checking JSON keys until it finished loading!

    Try this code:

    JSON has key "maps.test" -> Browser Log "HAS key, "&tickcount
    Else -> Browser Log "NO key, "&tickcount
    

    Open browser console and check the messages. You will probably see a couple of "NO key" before "HAS key" appear.

    I keep running into strange scenarios...

    JSON.CurrentKey works only inside "JSON For Each" loop. If you need to get current path outside the loop, use JSON.path expression.

  • When then I don't understand what you are struggling with. Where do you store these JSON strings after you get them from the server? What is the JSON structure?

    In pseudocode, you need do something like this:

    Array For Each X element
     JSON Parse (string for this X)
     Array set at X=Self.CurX, Y=1 value:JSON.Get("key_for_Y1")
     Array set at X=Self.CurX, Y=2 value:JSON.Get("key_for_Y2")
     Array set at X=Self.CurX, Y=3 value:JSON.Get("key_for_Y3")
    
  • Where do you get these five JSON strings from? Are they stored in files, or in another array or do you request them from a server?