Is it Possible to make my Enemy switch its Y Axis Like This?

0 favourites
  • 7 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • Im trying to figure out how to make my enemy switch its Y axis similar to How the Y axis of the enemies in this clip are.

    Ive marked it at the exact time where the action starts.

    Subscribe to Construct videos now

    Im just trying to make the enemy move to my players Y axis before he actually starts to move forward and attack if that makes sense.think you could give me a hand.

    I posted in the how do i section,I seemed to accumulate over one hundred veiws with zero replies,could someone here give me a hand with my situation perhaps?

  • I don't understand, if you want enemies to move up or down to the Player Y axis before moving forward, the player will just move up and down to prevent enemies from moving to attack him, no?

    Otherwise you can do a set Enemy.Y to Player.Y every tick so they run up or down as well as towards the player (via X movement) and will match the player's Y axis... but then every enemy will be on the same plane. You'll have to filter it with some variables.

    Hopefully some one else can chime in.

  • Thank you !!

    I do understand that setting my enemies .Y to my players .Y every tick will make it constant ,im trying to make the enemy spawn on different planes but then switch to the players. Y wheather it be Up or Down since the player can move up and down at will with the 8 direction behavior.

    Just like the video,the enemies are not always constant on the players .Y they move but when in close they then switch to constant and stay in front of the player. I just need to figure out how to make the enemy move to the players Y after the player does not mimicing every movement.

    Im sorry if im confusing,I really am explaing this to the best of my knowledge of the function.Thank you for giving me your input.

  • It's best if you divide your path to 4-5 different Y levels you want enemies to be on. Then just do a trigger checking for player Y, if less or greater than a certain level Y, trigger a boolean on enemies to move them up or down to another Y level, the movement can be smoothed out as per tick add delta time pixel Y.

    Or another approach is to do a pathfind behaviour, not to the player, but to another temporary sprite that you generate behind the player and call the update every few seconds to simulate enemies adapting to your player movement, but with a delay. I have a similar setup for my enemies in my Ninja fighting game (attached image), the black lines are pathfind boundary.

    Pigs spawn on the right and if its at the 2nd upper path, they scale their size according to their Y over time so as they run down they get bigger. They run towards a spot behind the player. You can easily change where enemies move if you get to them pathfind towards a sprite which you control the spawning based on player X/Y. Obviously if they are on the left of screen, they mirror and flip the art to travel back etc.

  • Thank you for you in depth reply,I have tried a few different methods and pathfinding is not what im looking for.

    I would love for you to try my capX file and see if you can explain alittle more in depth about DT and how to actually use it in game.I think i have everything down but that.I have learned alot from you and pixel perfick .

    here is my capX and im sorry for the confusion i may have caused along the way guys.Im just here to learn thats all.

    https://db.tt/AjhsNGSV

  • Sorry if this is messy its just my thought process. I cannot check your CAPX because Im still on an older C2 version for now.

    Here's a quick example of moving on Y axis with DT to give it a smooth transition (attached).

    200 * dt = 200 pixels over 1 second, but it moves per frame so its smooth.

    You can have your enemies trigger to move up or down using that and some variables/booleans. Here's how I would do it if not using Pathfinding.

    For example, your ground combat area has 4 Y-axis Level (1,2,3,4) you want enemies to travel to corresponding to 500, 550, 600, 650 on the Y axis.

    You do a check, Player.Y < 500 (Trigger Once) = Set global variable Level 1. And same for setting Level 2, Player.Y < 550 & > 500 etc.

    Add a trigger for your enemies. Level = 1 & Enemy.Y > 500 = set Enemy.Y to Self.Y - (200 * dt)

    Your enemy will move up gradually until he is on Y-axis 500 then stop going further up.

    If your player moves down, it will trigger the global variable Level to be 2. Then you have another movement trigger for Enemy, Level = 2 and sub-events Enemy.Y > 550 as well as another sub-event Enemy.Y < 550 (above and below 550/player Y) to move enemy up or down to match the player Y axis.

    If you combine it with Bullet Behaviour for X axis movement (angle of motion 0 or 180), the delta time Y axis will cover their Y axis movement for you.

    I hope that makes sense, it should work.

    Edit: Oh and for your 2nd point, you want enemies in close combat range to always maintain constant Y with player, just do a distance check.

    Compare two variables, distance(Player.X, Player.Y, Enemy.X, Enemy.Y) < 100 = set enemy instance variable (melee) to 1/true and set enemy.Y to player.Y

    Then filter out other far away enemies so they move up and down as above, by adding in a condition that check for Enemy.Melee = false etc before triggering the movement up or down.

    Messy thought process, apologies.

    Edit2: Actually if you just want enemies to spawn on their own Y axis and ONLY move toward the player in close combat to fight on the same Y axis, its even easier, just only use the distance check, set enemy instance variable Melee to true, and when its true, set Enemy.Y to move to Player.Y using dt.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Does this comes close to what you want..?

    http://www.eli0s.com/Tests/DoubleDragon.capx

    Use the arrow keys to move the green sprite (Player) and the red sprite (Enemy) will follow accordingly.

    Fiddle with the Every x seconds and with the EnemySpeed variable to get different results.

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