Delay on changing scenes

  • #1, by CrossWednesday, 10. October 2018, 08:45 5 years ago
    Hi guys,

    in my project i use direct character controls through "key actions" for both keyboard and gamepad (classic tank controls basically). I change scenes through entering action areas and instantly teleporting to a new scene.

    My problem is: when entering the new scene, there is a short delay of up to a second, where my character stops and doesn't continue walking, even though the key action is still pressed and executed. If i instead use the lua script for key movement provided by Simon there is no delay. Any ideas how i could get rid of the input-delay on changing scenes?

    Newbie

    92 Posts


  • #2, by afrlmeWednesday, 10. October 2018, 11:42 5 years ago
    Does it register the key if you quickly let go & press it again? Does it register any key press right after changing scene? Check with some print() functions or on screen indicators via an interface or scene objects.

    It could be possible that key interaction is disabled with key actions until the scene has finished loading.

    Imperator

    7278 Posts

  • #3, by CrossWednesday, 10. October 2018, 15:51 5 years ago
    I just checked: the keypress is registered instantly, when the character enters a new scene, but it will take up to a second, before he moves again. Strangely enough this happens only about 3/4 of the time, meaning that rarely it works seamless and fine.
    I dont think loading is the problem: i use low resolution (320 x 240) and also tried preloading the scenes, but it won`t change. 

    To quickly let go and press again works instantly, so somehow only the key action loop is delayed.

    Edit: i just tried teleporting within the same scene and the same thing happens: i call a send-to- destination-action through a key action and after teleporting the character stops for a second, before he restarts walking to destination.

    Newbie

    92 Posts

  • #4, by afrlmeWednesday, 10. October 2018, 16:03 5 years ago
    have you inserted a pause action part into the key action block? are you calling another action block via the key action? does that contain a pause action part?

    Imperator

    7278 Posts

  • #5, by CrossWednesday, 10. October 2018, 16:16 5 years ago
    I tried send-character-to-object, send-character-to-destination, send-character-to-character (= chase character). Only that one action bound to a key (pressed) and stoped when key is released. No pauses, no external actionparts called.

    Newbie

    92 Posts

  • #6, by afrlmeWednesday, 10. October 2018, 17:03 5 years ago
    Your reply is a little confusing. So in other words, none of those worked?

    Maybe the key pressed action gets cancelled/interrupted when changing scenes? I know for example, that looping action blocks & the Lua mainLoop event handlers also get paused while a scene is changed & loading, so maybe it's the same for key actions.

    If you said that the script of Simon's works, then why not use that? You should be able to modify it to work how you want it to work.

    Imperator

    7278 Posts

  • #7, by CrossWednesday, 10. October 2018, 18:38 5 years ago
    Yes, none of those simple actions work.
    It really can't be loading issues, since it also happens, when teleporting within the same room.
    Unfortunately i wouldn't know how to build a tank control system (relative movement) with the main loop event handler, since Simons script is for absolute movement only.

    I'm afraid i'm stuck again. But thanks for the help Lee.

    Newbie

    92 Posts

  • #8, by afrlmeWednesday, 10. October 2018, 19:12 5 years ago
    Yes, none of those simple actions work.
    It really can't be loading issues, since it also happens, when teleporting within the same room.
    Unfortunately i wouldn't know how to build a tank control system (relative movement) with the main loop event handler, since Simons script is for absolute movement only.

    I'm afraid i'm stuck again. But thanks for the help Lee.
    You would need to use range values if you want to limit movement to north, south, east, & west only without diagonal movement. Keyboard one would require you to cancel out movement if any more than one direction key is pressed. You could do that by incrementing/decrementing a value whenever a direction key is pressed or released, so in other words if the value does not equal 1 then the script should ignore the movement.

    Imperator

    7278 Posts