why the 8-way behavior I applied to the enemy doesn't work?

0 favourites
  • 8 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello, before coming to see you to ask you if you have a solution to my problem, I went to read the whole manual and look for information on the internet about 8-way behavior, I didn't find a solution to my problem, I also looked at the settings, I don't understand why after giving the 8-way behavior to the enemy, why it stays frozen, I'll link you to my game, please check my games and if you can tell me what I should do as to activate the enemy's movement. Thank you in advance for your advice, which I must apply.

    dropbox.com/s/ndhqr994u41v9gh/Arena%20%288%29.c3p

  • i haven't look into your code but did you also create logic to simulate the movement? or are you, the player, controlling the enemies with the keyboard or some other kind of input (keyboard/touch)? there needs to be something that actually tells it to move in a set direction.

    you could do; every x seconds [for x enemy] simulate movement up/down/left/right

    or also; on left arrow key hit [for x enemy] move left

    etc...

  • Thank you very much for your help, yes I created a logic with control simulation to the enemy. I do not understand why it does not work. I will follow your advice. Again thank you very much for your advice. I would follow up to indicate whether I can get the enemy movement to work or not.

  • I test your advise to apply the logic: every x seconds simulate a movement up, down, left, right but still no movement. Please, you can look at my game to see if you can see what is preventing it from working, I have a good look and look but I do not see who can block the movement of the enemy. thank you in advance for your response.

  • An input every X seconds will result in a very fast input to the movement...

    What you need to do is make conditions and meet them to release a movement every tick while the condition is true, i.e.:

    - Player is in LOS:

    -- Check Player position:

    --- Add conditions to refine it's position against the enemy: Simulate control ABC to the enemy.

    That's why I prefer pathfinder instead of simulate control.

    But, if you want make a platform game with an enemy walking left/right in a pattern, it's simpler, just put the condition:

    Local variable Side: 0;

    - Enemy Is on the screen:

    -- If Side is 0: Simulate control Left;

    -- Else: Right;

    - Every 2 seconds: Side = choose(0,1);

    Download some tutorials or take a look inside C2 sample files to understand more about the logics and remember, always when you have something happening along the way, it need to happen also in the events, otherwise, it will happen only when the condition is meet. Conditions like Every Tick give you continuous true if you don't check another condition with it.

  • thank you very much for helping me, I made a game in top view, my hero in the behavior 8 direction, for a game seen from above you prefer to give the behavior patchfinder that simulate the control? For patchfinder it is also los to the enemy or the player? Thank you very much for having me well advised.

  • took a look at ur project, sorry i wasn't specific enough,

    if you are looking to use the simulate movement logic try setting it so that (the numbers here are just examples to start with, tinker for what you want);

    every 8 seconds simulate left

    then separate event

    every 12 seconds simulate up

    then separate event

    every 18 seconds simulate down

    then separate event

    every 21 seconds simulate right

    the reason it isn't working is that it is saying every 1 second to simulate movement left, right, up and down whereas you want it to switch between all four at different points

    if you want to do pathfinding to player you will need to decide the condition that determines what decides if they are moving towards the plater (for instance it might have to do with what size the player is, if the player has BIG = true then have enemies target player and move towards them(BIG would be either a global/instance variable, then just decide the condition that determines what toggles the BIG true/false) if BIG is false then disable pathfinding (which is as simple as setting stop pathfinding i'm pretty sure), you could also use line of sight behavior functionality if that floats your boat, though i haven't used line of sight very much so i recommend looking up any tutorials for it you can find, however;

    first add pathfinding behavior to your enemies

    once you decide your condition then the pathfinding logic looks like this;

    is pathfinding condition met (BIG =true/false, or maybe LOS to player =true/false, etc...)

    then

    on condition met -- enemy find path to (player.x, player.y)

    on pathfinding failed to find path -- find path to (player.x, player.y)

    on pathfinding path arrived -- find path to (player.x, player.y)

    then you want to have;

    on path found -- move along path

    this will not only have your enemy move along the path when the condition(s) is/are met, but will have them continue to track the player whether they arrive at the player's position or if they get stuck and fail to find a path

    personally i used both simulate movement(s) (up/down/left/right) and pathfinding in my project so that even when pathfinding is not active the enemies move around the map

    but you can do what you want, you know?

    you may also try referencing this:

    scirra.com/manual/154/pathfinding

    helped me quite a bit in understanding how pathfinding works

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you very much I took time to understand and find out how to do it, your advice has been very helpful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)