Keyboard controls

  • #1, by Simon_ASAMonday, 06. July 2015, 16:37 9 years ago
    Hello, I would like to try to add an alternative gameplay in my game. I have a first person view (Myst-like) where it is possible to play with the mouse as usual, but I also try to allow the keyboard for navigation.

    Currently when the player clicks on a hotspot in the middle of the screen, he moves to the next frame. However, I try also to do the same when the player clicks on Z (for ZQSD commands /Azerty keyboards), or upper arrow.

    Do you see what I mean?
    It sounds easy to do, but I'm stuck roll

    Great Poster

    321 Posts


  • #2, by ke4Monday, 06. July 2015, 16:56 9 years ago
    There is a key actions tab in the main game tab in Visionaire or did you use that but it didn't work?

    Key Killer

    810 Posts

  • #3, by Simon_ASAMonday, 06. July 2015, 17:41 9 years ago
    Thanks Ke4 smile
    Yes I know the key actions tab and I tried to use it, but I think I have not found the logic for this specific purpose.

    If I choose the Z key to move forward, for example:
    How can I really move forward on pressing Z ? Moving forward is different in every frame: the "next frame" could be the path on the right or the path behind. Gah! It's hard to explain!
    In fact the best solution would be in the Actions tab of each scene object, to have the possibility to add a key. Instead of choosing "on Left click", I would have to choose "on Z key pressed". Then I choose the good action.

    Great Poster

    321 Posts

  • #4, by ke4Monday, 06. July 2015, 18:26 9 years ago
    Well don't know if that's a good idea but this is what i can think of grin

    I guess you could store in each scene the action for the move and it would be named in all scenes the same ( eg. "next frame" ) and everytime when you would press the Z key it would call the "next frame" action from the current scene

    Key Killer

    810 Posts

  • #5, by Simon_ASAMonday, 06. July 2015, 18:32 9 years ago
    lol
    Yes it sounds like a working solution, and so easy to set up. I must start to be tired, I have been doing things much more complicated than that haha!
    Thanks A LOT! You saved me ^^

    Great Poster

    321 Posts

  • #6, by ke4Monday, 06. July 2015, 18:43 9 years ago
    Don't worry i remeber how i was trying to set up a minigame with cables and i overcomplicated it so much grin

    The code would be something like
    startAction("Game.GameCurrentScene.SceneActions[nextFrame]")
    

    Key Killer

    810 Posts

  • #7, by Simon_ASATuesday, 07. July 2015, 18:07 9 years ago
    Thanks for your help, but I think I'm going to give up. It's too much additional work if I have to manage a key for each hotspot that takes to a new place. There are a very lot of frames to visit, so... roll

    Great Poster

    321 Posts

  • #8, by ke4Tuesday, 07. July 2015, 18:54 9 years ago
    I'm not sure what you mean now. You would be calling the action what you have already done for the mouse action in your scene.

    Or it's more complicated then just moving forward/backward?

    Key Killer

    810 Posts

  • #9, by afrlmeTuesday, 07. July 2015, 19:03 9 years ago
    You could create some Lua tables for each scene to determine which scene you should go to when pressing a specified direction key.

    Tables are relatively quick to type up. Much faster than creating a ton of actions parts & so on anyway.

    local t = {} -- create a new local table called "t"
    -- + --
    t["exterior"] = {n = "interior_n"}
    t["interior_n"] = {e = "interior_e", w = "interior_w", n = "reception_area", s = "interior_s"}
    -- etc.
    
    function changeScene(dir)
     if t[game.CurrentScene:getName()][dir] then
      game.CurrentScene = Scenes[ t[game.CurrentScene:getName()][dir] ]
     end
    end
    

    ... you only need to specify directions required for each scene. Then using the lua key handler or the key actions in the editor you have it execute a function that changes to the required scene based on the table of current scene & key that was pressed.
    changeScene("n")
    

    ... something along those lines. It's all theoretical of course though. As per! grin

    Imperator

    7278 Posts

  • #10, by afrlmeTuesday, 07. July 2015, 19:07 9 years ago
    I'm not sure what you mean now. You would be calling the action what you have already done for the mouse action in your scene.

    Or it's more complicated then just moving forward/backward?


    First person exploration games like Myst are always complicated in their own way, as they often have multiple views of the same scene from different angles (panoramic 360º views quite often); north, south, east & west. At a minimum there may only be one direction to go, but more often there will be 2 to 4 directions in each room & then possibly more depending on depth of room - close-ups etc.

    Imperator

    7278 Posts

  • #11, by ke4Tuesday, 07. July 2015, 19:17 9 years ago
    Sound complicated enough. I thought that if there is in each scene classic object button for move (up, down, left, right) they could be named in each scene same and it would call always the "up" or "right" action from the current scene. But as you said, there are often different angles in each scene.

    Key Killer

    810 Posts