Why are all obj_enemy going south?

0 favourites
  • 9 posts
From the Asset Store
Warm temple themed set of tiles for your platformer game.
  • All my obj_enemy assets are going straight to the bottom, and I don't know why...

    As you can see, I have set all 3 to LoS with obj_green_food, yet they all just head straight down to the bottom, directly above their respective sprite... For the life of me I can't seem to work out what is going on with these morons!

    More Artificial Ignorance going on

    drive.google.com/open

    Also, I've probably done the link to the file wrong, so my appologies

  • Hypozonic

    I think the problem is that you have the background image set as solid, so the line-of-sight never sees any food, because the entire layout is one giant obstacle. When I turn off solid on the background it seems to work fine...

    other bugs: you are destroying food when the enemy arrives at the target position, but it doesn't remember the specific food that was targeted, so it destroys ALL food. You want to destroy the food when the enemy collides with a food - then only that one will be picked and you can destroy it.

    also, sometimes the enemies set a path that wants to take them off screen, but they can never get there so they get stuck at the edge of the screen...

    oh, the reason they were going straight down was that you have the initial food object below the layout, and the enemies were targeting that...

  • I set background to not solid and I’m getting light blue on heading straight to bottom, which could be as ya said, setting a path for the off screen food. But how to I make this not happen?

    I’ve tried setting food to solid but that still made food disappear. I set background initially to solid as it was only this I could do to stop food all destroying.

    It’s a case of have food that doesn’t all get destroyed, but have enemies that path straight to bottom, or have food that gets destroyed and enemies that kind of do what they are supposed too.

    I’m slowly but surely getting to grips with other stuff, but this issue has been like a cheese grater on my brain for a couple of weeks now.

    Sorry late addition

    I've moved the initial assets too top, and as you can see they are spawning below there respective initial assets...

    food is too left of layout, and nothing there at all. Enemies are at top, all three...

    I set obstacles to custom, so to force ignorance of the solidified background, thinking this would work. I have concluded that this is what is causing the morons to get stuck up top... they cant spawn on the solid background, so they are spawning slap bang below the initial asset.

    Also, why can player move freely around on it the solidified background?

    Holy fart bags, I'm stumped....

    drive.google.com/file/d/1Hd5XyLyh-0UQMkFKy8baHOTJWcT0ARFS/view

  • Hypozonic

    well, I played around with your game quite a bit, and made lots of changes... and there are still a lot of things I would do differently, but I have other things I should be working on :)

    to make the enemies not target food outside the layout, you have to make sure it is out of range, or better yet, destroy all food at the beginning of the game (Start of Layout) - before new food starts to randomly generate.

    I made the mouse wheel zoom in and out of the layout so that I could check up on all the enemies...

    I made the enemies bump apart if they run into each other, and look for new food.

    I also tried a alternative method to find food for the dark enemies (using a "detector" sprite instead of line of sight. That lets you select whatever food is near the enemy and then choose the closest.

    For some reason the path finding sometimes just fails to find a path, so in the dark enemy section I have it just randomly put the enemy somewhere else and try again...

    Now, the only time I have seen an enemy get stuck is if it is trying to get to a food near the edge of the screen but can't quite get there. (You can click on an enemy and the food it is going for will flash).

    I made the dark enemies grow much faster than you had them, just to speed up debugging...

    you can download my version of your game here:

    https://www.rieperts.com/games/forum/agar_tester2.c3p

  • Thank you Allan.

    You've helped no end.

    The detector is working fantastically.

    I'll get my head around these UIDs, doesn't look to complicated, Just a new concept I'll have to learn eventually.

    Do you have any idea why I am still spawning 2 of each enemy.

  • Yes, you have the 3 enemies on the layout (at the top), and then in your code at the start of the layout you create one of each, so you end up with doubles.

    Normally, at the start of layout I Destroy objects like your food and enemies, and then create them as needed...

    since you have code that recreates the enemies when they get destroyed, if you have your game destroy them at the start of layout they will automatically re-spawn.

    so, either have the start of layout code destroy them, or just set their positions to a random location. But either way, take out the lines where you create new ones at the start.

  • That’s what I don’t understand.

    I’ve got the assets outside of layout, but I’m also spawning 1 of each colour directly below there respective asset.

    Along with the ones I have spawn event for.

    So I took a leaf out of your book, and figured I’ll just destroy them on start up, and that made them not appear up top, but instead I have 2 of each spawning at random locations around the layout...

    I haven’t physically placed 3 at the top, they’ve always just appeared there, or where ever I place the off screen asset, regardless of distance from layout.

  • Hypozonic

    because they have the "Bound to Layout" behavior, as soon as the layout starts, they automatically get moved into the layout.

    And, like I said, if you destroy them at the start, they will get automatically recreated because of the code in each of the enemy sections:

    Enemy -> On Destroy - Create Object Enemy...

    so, that is why you don't need to have the Create Object lines in the Start of Layout section.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oooooooh, I got ya now.

    It’s usually quite late when I read replies. And brain just minced all the words up.

    Thanks Allan

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