thepeach's Forum Posts

  • Thanks for posting about this. I had a similar issue with the bullet behavior. I wanted to destroy instances after they bounced off of a solid a couple times, but testOverlapSolid() always returns false for instances where the bounceOffSolids property is true.

    I used a similar solution to what’s been discussed here (tailored to the bullet behavior), and am planning to handle instances with the platform behavior as above. I agree this isn't the smoothest implementation, especially if it needs tweaks for different behaviors. That said, it gets the job done for now.

  • Update: This workaround is no longer needed! r338 added the timeScale property and restoreTimeScale method to the scripting API.

  • ChatGPT is pretty helpful for scripting, especially for problems that aren't specific to the C3 API. The solutions usually point me in the right direction even when they're incorrect. That said, it frequently has hallucinations when writing C3 API code. I expect this will improve over time.

  • My understanding is that time scale functions are not accessible via the scripting interface in Construct. I am new to the software and unsure why that is the case. However, a workaround for this limitation is to use event sheet functions that can be called from script files. Here's an example:

    runtime.callFunction('PauseTimeScale')

  • The short answer is yes.

    Under the hood, Construct's Gamepad plugin uses the Gamepad API, which does support Switch Joy-Con controllers. You can test your connection using this demo page.

    With that said, Joy-Con controllers don't have a D-pad, and you might have mixed results with the analog stick. Construct's Gamepad plugin attempts to remap input from the Standard Gamepad layout to the Xbox 360 controller layout. Therefore, you may be better off using an Xbox 360 controller, PS4-5 controller, Nintendo Pro Controller, etc.

  • Ashley Thank you! That solution didn't even occur to me. I'll try it out.

  • Can anyone offer advice on using gamepads in a script-based project? I understand it's necessary to use an event sheet because the Gamepad plugin isn't accessible to the scripting interface. Here are some of my goals for the implementation:

    1. Pass Gamepad plugin data to a script file from an event sheet.
    2. Avoid introducing side effects in the event sheet.
    3. Avoid mutable global variables.

    Here's my latest attempt for the event sheet. This would be fine if I could return the data to my script file.

  • The current solution is to call an event sheet function returning the value(s) you want. Here is an example that returns the default width for a Sprite Font object named "SpriteFont":

    const width = runtime.callFunction('GetCharacterWidth');
    
  • For posterity, the suggestion can be voted on here.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your reply! Is it possible to set the time scale to 0 for testing without using an event sheet? It seems like it's not based on this discussion.

  • Just for clarity, this.#runtime.objects.Camera.getFirstPickedInstance() is a sprite with the scrollTo behavior enabled.

  • Ashley's 2017 article on delta-time says:

    Don't forget behaviors already use dt. If you use behaviors to control all motion in your game, you don't have to worry about dt at all!

    So, can I ignore delta-time when using the lerp function to position a sprite with the ScrollTo behavior? For context, see the comments in my code below:

    const lerp = (start, stop, amount) => amount * (stop - start) + start;
    
    export default class Game {
     #runtime;
     #camera;
     #player;
    
     start(runtime) {
     this.#runtime = runtime;
     this.#camera = this.#runtime.objects.Camera.getFirstPickedInstance();
     this.#player = this.#runtime.objects.Player.getFirstPickedInstance();
     this.#runtime.addEventListener('tick', () => this.#onTick());
     }
    
     #onTick() {
     // Do I need `this.#runtime.dt` here?
     // Or, does the scrollTo behavior already use it?
     const amount = 0.3 * this.#runtime.dt;
     // Move the camera to the player's position using lerp.
     this.#camera.x = lerp(this.#camera.x, this.#player.x, amount);
     this.#camera.y = lerp(this.#camera.y, this.#player.y, amount);
     }
    }
    
  • I have a layout that uses the default Sprite Font object. The character width and height are both set to 16 in the editor. Is it possible to get the corresponding property values in a script file? For example, something like the following where `SpriteFont` is the object's name:

    `runtime.objects.SpriteFont.getFirstInstance().characterSize.width`