How can I create a mechanism based on the 8 direction movement ? (Problems solved)

Julio84Julio84 Member, PRO Posts: 19
edited March 2020 in Working with GS (Mac)

@adent42 @SpriteAttack @ForumNinja :) Hello to all the Gamesalad community, to start I want to clarify that before coming to see you I have watched the tutorial videos which are on the Gamesalad site, not all but the most important courses, I also followed a course on youtube and I did not find an answer to my problem. I would like to create a topdown game, I saw in the videos that it is possible and easy but my concern I want to create a game or my character and the enemies can have a movement in 8 direction, not only to make them move by left right and bottom up ... but they can also move diagonally. How can I make a move and move them in the 8 direction? So I would like to give my characters and enemies a different sprite for 8 direction? Thank you in advance for your precious help, I am completely blocked.

Comments

  • Julio84Julio84 Member, PRO Posts: 19

    @bob loblaw Yes it's a movement like this that I want to attribute to my character and my enemies but but without the virtual joystick I want to move my character to the touch, how I can perform movement of 8 direction and assign a different sprit to each Direction? Thank you for your help. I'm looking everywhere I can't find solutions.

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,172

    Set up 4 game level boolean attributes: N,S,E,W.

    Set up 8 rules: N = true, S = true, E = true, W = true, and for each combination.

    Inside each rule, change the animation or actor image.
    Inside each rule, change the movement direction of the actor to match those values.

    Whatever actor you are using for controls, set the NSEW values accordingly.

    Hope that helps?

  • Julio84Julio84 Member, PRO Posts: 19

    @bob loblaw I asked the suport, they answered me and solve my problems, I make a copy paste of their answers if it helps other people.

    1st answer for the 8-direction movement : Hello!
    The easiest way to do this would be with the move behavior. For the direction values you'll want to use in it:
    Right: 0
    Up-Right: 45
    Up: 90
    Up-Left: 135
    Left: 180
    Bottom-Left: 225
    Bottom: 270
    Bottom-Right: 315

    For the movement it looks like you can leave the movement type as "additive" and just do the 4 major directions (up, down, left, right). Then when up and right are pressed together it will just go diagonally automatically.
    For making the actor face the direction it's moving you can constrain its rotation to a neat function called "vectorToAngle" with the x and y linear velocities filled in for the placeholders in the function.

  • Julio84Julio84 Member, PRO Posts: 19
    edited March 2020

    @adent42 Thank you very much to you but it seems to me that the answer of suport suits me better

  • bob loblawbob loblaw Member, PRO Posts: 793

    both answer should work, but you’ll probably have to add rules if the player presses conflicting combinations (eg. what if north and south are somehow pressed together).

  • Julio84Julio84 Member, PRO Posts: 19
    edited March 2020

    @bob loblaw @adent42 What rules could I add, can you explain if you like?

  • bob loblawbob loblaw Member, PRO Posts: 793

    this file is a really basic demo of it. it would need some fine tuning to make it game worthy but hopefully that helps you get your head around it. it's similar to what adent was describing.

    the demo i put up before uses joystick angles constrained to the player movement and image. it uses 36 different images to give the effect. using a joystick means you don't need to put in conflict direction rules, like you'd need if using a dpad. that type of thing could be adapted to work with only 8 directions/images as well, very similar to what support sent you (I'd use a range of angles moving in 45 degree increments to determine the direction rather than an exact value though)

  • Julio84Julio84 Member, PRO Posts: 19

    @bob loblaw @adent42 Thank you for your explanation and for the demo but I think that my explaining the support should be sufficient since I do not use joystick but I move my character to the touch, I will make it move to the place that touches the mouse or my fingers . Anyhow, thanks for your help.

  • bob loblawbob loblaw Member, PRO Posts: 793
    edited March 2020

    no problem, Freddy. good luck with it.

    just one thing to keep in mind if you're making a pseudo 3d type game, because you're working with a 2d engine, you need to take into account the actors' positioning in the layers heirarchy if you're moving around other actors. eg, if your player runs around a pole, you'd need two pole actors, one positioned infront of your player and one positioned behind, with whichever one is displayed determined by the players position (while the other one becomes invisible).

    if a regular 2d game, then ignore the above.

Sign In or Register to comment.