Passing the SOL from conditions to Javascript blocks, What is the way?

0 favourites
  • 2 posts
From the Asset Store
Assets for creating mountains and ravines environments
  • I'm not clear on how you are supposed to do this atm.

    I've looked through some of the examples, but they always seem super basic, or all JS is in the main.js file, instead of the event sheet.

    for (const inst of runtime.objects.Character.instances())
    {
    	inst.instVars.vX = m.x;
    	inst.instVars.vY = m.y;
    }
    

    For example, is the above selevting ALL instances of Character, or just the ones as picked by the eventsheet conditions at that point?

    Whatever the case, doing the above 1000 times with only 1 Character in the scene adds 10% cpu load, which makes it feel like I'm doing something terribly wrong with that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Picking is a concept that only applies to event sheets. There is no notion of picking in JavaScript code. So that code operates on all instances of Character and has no involvement in picking whatsoever.

    However from a code block in an event sheet, you can use pickedInstances() to iterate just the instances picked in the currently running event block. You could then also pass these to a function in a script file. But that doesn't mean JavaScript understands picking - from the perspective of JavaScript it just means you're passing an iterator (or array) with some specific subset of content.

    Whatever the case, doing the above 1000 times with only 1 Character in the scene adds 10% cpu load, which makes it feel like I'm doing something terribly wrong with that.

    Ignore such measurements, for the reasons I described here.

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