[Solved] Walking with arrow keys

  • #10, z Simon_ASAThursday, 12. January 2017, 11:11 hodinky 8 years ago
    there's currently a bug if there are less than 2 shapes in the waysystem if I remember correctly.
    Thanks Simon! What do you mean by 2 shapes? I have 1 shape for the way borders and 1 for the way points.
    I'll make some tests by creating more shapes in these systems. We'll see if it helps!

    do you see omething in the log?

    this line: print('key pressed: ' .. keycode) should print the keycode when pressing a key...
    No, you're right!! As I noticed before, there's nothing in my log. I thought it was good news, but in fact it might prove there's an issue. I have to find it...
    I try to do everything clean and fix the mistakes in the log as often as possible, so if the log is empty it's difficult to find the problem........

    Thanks to both of you! Let me know if I can help too smile

    Čestný člen

    321 Posts


  • #11, z bananeisafreeThursday, 12. January 2017, 12:23 hodinky 8 years ago
    That's very weird !

    And you say that the caracted actually turns around ? yet no feedback in the log ?
    Man that is VERY very strange.


    Well if you ever manage to make it work, I did a bit of fiddling around. and I would reccomend to change the first chunck of code (the one regarding what happens if the key is released) by this :

    function keyboardHandler(eventType, character, keycode, modifiers)
    
        if eventType==eEvtKeyUp then
    
            print('key up: ' .. keycode)
    
            keycode = keycode % 1073741824
    
            if keycode == 80 then -- left
    
      if charmove_x ~= 100 then -- as long as char is not going right
    
                  charmove_x = 0
    
      end
    
            elseif keycode == 79 then -- right
    
      if charmove_x ~= -100 then -- as long as char is not going left
    
                  charmove_x = 0
    
      end
    
            elseif keycode == 81 then -- down
    
      if charmove_y ~= -100 then -- as long as char is not going up
    
                  charmove_y = 0
    
      end
    
            elseif keycode == 82 then -- up
    
      if charmove_y ~= 100 then -- as long as char is not going down
    
                  charmove_y = 0
    
      end
    
            end
    
            createEvent('eEvtControllerAxisCharacterMove', {x=charmove_x, y=charmove_y},25)

    It's a first improvement that will prevent the character to stop if you do for exemple :

    press left (char move left), press right (char move right), release left (with the original version the char would stop then resume moving to the right, here it just keep on moving right).

    There is still lots of room for improvement, I may look it up later.

    cheers

    Fanoušek fóra

    120 Posts

  • #12, z Simon_ASAThursday, 12. January 2017, 18:47 hodinky 8 years ago
    Thanks bananeisafree, I'll try your script update if I can manage to makethe complete one to work in my game.

    Actually I'm totally stuck. If someone wanted to have a look, I'd apreciate it: I have recreated a clean scene with only the character and background + the main script.

    I have the same result as always: pressing the keyboard arrows change the character orientation but he doesn't walk.

    This is the download link:
    http://bit.ly/2jIHwGP

    Thanks, I hope that someone will find the issue. I'm almost sure that it's a silly thing that I must forget, but I can't find where :p

    Čestný člen

    321 Posts

  • #13, z bananeisafreeThursday, 12. January 2017, 19:21 hodinky 8 years ago
    I downloaded your test and I think I figured it out !!!

    Basically you have to create a second wayborder area (a useless one, just put it where your character will never go).

    For some reason it makes your character able to move with the keys (you still need waypoints too, they were none in the ved you provided, but I think it was intended).

    I did not have the problem with my projects because there always are non walkable objects in my scenes. wich mean that always had a second wayborder area polygon.

    Let me know if this works !

    Fanoušek fóra

    120 Posts

  • #14, z sebastianThursday, 12. January 2017, 19:39 hodinky 8 years ago
    Tested your project and the only difference with mine is that it only has one walkable area and no waypoints.

    I'll try to creating a new area or adding one to compare now smile

    EDIT: Ah damn.bananeisfree was faster XD (didnt reload the page) . It seems that the second area would solve it. 

    Kapitán

    2346 Posts

  • #15, z bananeisafreeThursday, 12. January 2017, 19:53 hodinky 8 years ago
    Yeah I was quite frustrated by the whole thing :p ...

    Fanoušek fóra

    120 Posts

  • #16, z Simon_ASAThursday, 12. January 2017, 22:30 hodinky 8 years ago
    Aaaah it works!!! Thanks a LOT banane and sebastian!

    In fact I had already tried it, because it was the suggestion of SimonS before. But I didn't understand it correctly: I had created the 2nd waypoints in a 2nd waysystem.
    So I didn't create the 2nd waypoints in the same system.. Now it works.

    Indeed I don't understand why we have to do it, but it works, it's the most important grin Ah it's so great. Tomorrow I can work on the game again and make important progress.

    THANKS!!
    I hope I can help you someday too.

    http://www.zupimages.net/up/17/05/hwdo.jpg

    Čestný člen

    321 Posts

  • #17, z sebastianThursday, 12. January 2017, 22:44 hodinky 8 years ago
    Aaaah it works!!! Thanks a LOT banane and sebastian!

    In fact I had already tried it, because it was the suggestion of SimonS before. But I didn't understand it correctly: I had created the 2nd waypoints in a 2nd waysystem.
    So I didn't create the 2nd waypoints in the same system.. Now it works.

    Indeed I don't understand why we have to do it, but it works, it's the most important grin Ah it's so great. Tomorrow I can work on the game again and make important progress.

    THANKS!!
    I hope I can help you someday too.
    for me it works with a second wayborder polygon inside the same system razz

    Kapitán

    2346 Posts

  • #18, z Simon_ASAFriday, 13. January 2017, 12:00 hodinky 8 years ago
    Yes that's it, exactly! smile Probably I didn't explain well.

    Čestný člen

    321 Posts

  • #19, z Simon_ASATuesday, 24. January 2017, 15:06 hodinky 8 years ago
    I'm still experiencing issues with keyboard gameplay (different issue this time).

    I have updated the small Ved file that I shared earlier: http://bit.ly/2jNfLd0

    The kayboard gameplay is working (it is possible to move the character with arrows)
    however there's a problem to change scene.
    Scene1 -> scene 2 = ok
    Scene2 -> scene 1 = fails
    I think it's obvious enough when you download and play the VS demo from the link above.

    It's strange, I have the same issue in my full project and I can't solve it....... roll

    Čestný člen

    321 Posts

  • #20, z bananeisafreeTuesday, 24. January 2017, 15:29 hodinky 8 years ago
    I think you are overthinking the action area system.

    Ditch the object and its related action called by another action.

    In the action area (in the way system tab) just choose change sceene and it will work perfectly wink

    Fanoušek fóra

    120 Posts