fanadventures.net

Header
English
 
Forum overview > Can we use the keyboard for the character movements?
  • by AkcayKaraazmak · Wednesday, 07. October 2015, 15:36 h ~ 5 years ago
    @Cross, I didnt understand how to use this matesmile Where we should create that action and this code is just for S key?
    AkcayKaraazmak
  • by afrlme · Wednesday, 07. October 2015, 15:54 h ~ 5 years ago
    He's talking about the key actions tab found under game category. WASD key movement.

    You don't actually have to create a loop as regular key actions automatically loop while you are pressing the key down. To regulate how often it loops you should add a pause action part to the end of the action list.

    Create an execute a script action for each key you want to use for controlling the movement & include these lines...

    south...

    game.CurrentCharacter.Destination = { x = game.CurrentCharacter.Position.x, y = (game.CurrentCharacter.Position.y + 20) }

    1

    north...

    game.CurrentCharacter.Destination = { x = game.CurrentCharacter.Position.x, y = (game.CurrentCharacter.Position.y +
    - 20) }

    1
    2

    east...

    game.CurrentCharacter.Destination = { x = (game.CurrentCharacter.Position.x + 20), y = game.CurrentCharacter.Position.y }

    1

    west...

    game.CurrentCharacter.Destination = { x = (game.CurrentCharacter.Position.x - 20), y = game.CurrentCharacter.Position.y }

    1


    You may want to add a small pause action part after the execute a script action to prevent the engine from looping the actions too quickly. Say 50ms or something.

    You may also want to come up with some method of determining if more than one key is pressed or for if you want to allow diagonal movement.
    afrlme
  • by AkcayKaraazmak · Wednesday, 07. October 2015, 16:00 h ~ 5 years ago
    Thank you Lee, I will try this.
    AkcayKaraazmak
  • by tristan-kang · Wednesday, 07. October 2015, 17:31 h ~ 5 years ago
    So if I want to play animation then...


    Play animation "character move - left" (no check wait before animation complete)
    Execute script - game.CurrentCharacter.Destination = { a = (game.CurrentCharacter.Position.x - 20), y = game.CurrentCharacter.Position.y }
    pause xxx ms (based on animation length)

    1
    2
    3


    It will be right?
    tristan-kang
  • by afrlme · Wednesday, 07. October 2015, 18:23 h ~ 5 years ago
    eh?

    game.CurrentCharacter.Destination is what is set each time you left click on a scene to make the character move to a new position or object.

    So simply updating the destination values means the table is no longer empty & will change the character to the walk animations automatically.

    Inside of a key (released) version of the key events you should include a stop character action part to cancel the characters movement.
    afrlme
  • by tristan-kang · Wednesday, 07. October 2015, 19:06 h ~ 5 years ago
    I tried it and it worked. Holding WASD button makes the character move infinitely just like most games did. But when you first hold WASD button the characters stops once and it didn't move smoothly.
    tristan-kang
  • by afrlme · Wednesday, 07. October 2015, 19:17 h ~ 5 years ago
    It's probably down to the movement value specified. The lower the value the less chance you give the engine enough time to loop before updating the destination values before they end up empty. When a character reaches it's destination it will automatically trigger the stop character event.
    afrlme
  • by tristan-kang · Wednesday, 07. October 2015, 19:24 h ~ 5 years ago
    But when I downed the value the character's moving animation stops at the middle of process. 20 is ideal.
    tristan-kang
  • by afrlme · Wednesday, 07. October 2015, 21:07 h ~ 5 years ago
    I said the lower the value the less likely it is to work, but the higher the value the more chance you have of your character falling short of the way borders.
    afrlme
  • by tristan-kang · Wednesday, 07. October 2015, 21:12 h ~ 5 years ago
    Damn how I omitted that part. roll I'm still suck at English...

    So I increased the value up to 250 and it works perfectly. I wonder Akcay did this magic too.
    tristan-kang
  • by AkcayKaraazmak · Thursday, 08. October 2015, 10:23 h ~ 5 years ago
    Ovv it really worked mate and character doesnt pass the borders???
    AkcayKaraazmak
  • New post