CJD's Forum Posts

  • Shame this went inactive after 21, now 22 posts.

    Looks like I'll have to start another sometime soon.

  • Getting a new issue that might stump me for awhile, picked count will pick the correct number of instances colliding with AIGroup,

    But occasionally it'll add 1 extra to that count, this is a tad annoying.

    Instances dont overlap it again, it just adds one to the final count.

    The event is triggered once for all overlapping instances,

    Oh it also SPAWNS IN with a count of 1, despite not overlapping any AI yet.

    My temporary fix is to just -1 from the final count and double check that its for each group rather than all of them, I feel like this is running from the issue and not actually fixing it,

    Any ideas?

  • Small issue, why does pickedcount only return one?

    So I changed the method of counting collided instances of my sprite "AIGroup"

    In my head, Pick by AI Overlapping my AIGroup Sprite, Set the value of counted AI to Picked Count.

    This only returns 1 for whatever reason, is picked count some kind of Boolean Expression where 0 is it picked nothing and 1 is something?

    Im kinda disappointed if so.

    I need picked count to return the number of picked instances, which it doesn't seem to do.

    Edit: I changed out my pick method to pick by comparison and it worked, I'm good now lol.

  • Definitely a welcome surprise to get resources for this,

    I guess this problem has become so much of a mess that the only thing everyone can do is throw calculators at it.

    Shame I'm taking acouple lenses off my scope, but I may come back in the future because for reasons I explained above,

    both of my solutions kinda suck in their own ways! So although they'd work fine I may need to swap them out for a formula generated by these calculators.

    I might know trigonometry, but I definitely don't feel like using that knowledge for anything more than operating a calculator lol.

    That plus I'm sure it'll work, that golden 1 line of code, 1 expression quota is too attractive for me to give it up.

  • Alright I've settled on a simple solution with a complex one being tried out in the future.

    Thanks for the website you gave me, it's an excellent resource to have, and thanks for the assistance; Really helped me think.

    The solution I settled on was just making a box, don't move it, don't do anything but count, and elect a leader from that count then finally delete the box once a horde is established.

    The lead makes a call to action zone, anyone outside of it isn't effected and is left behind.

    The call to action zone then makes a mid point, or final destination in its center which they all move to.

    Destinations are stored in a library, which I can curate by typing it in.

    Its not costly for performance, I don't think, they all behave in unison but can easily break off and do literally anything else if interrupted.

    Anytime a AI is interrupted but then left alone after a while, it returns to walking down that route.

  • Nope, it only follows and counts, I could have it change size to fit more but Id rather control that through a variable.

    Perhaps an elected lead soldier would have more influence, thus a greater horde range.

    In the old thread I did something similar to that line work with the only difference being a box follows the line at its middle image point, the square would change its width and height to equal the length of that line.

    It works but having that many instances all at once just to do something that could probably be done mathematically seems abit much.

    Itll fix my problem but make another one in its place.

    But yes, I know its anti-climatic but I literally am just asking how to make a box follow between multiple AI, only letting them go if they stray too far.

  • Looks like I am terrible at constructing sentences,

    No you are absolutely correct, sort of.

    Your assuming they all act in unison which I dont want them to, having so many chances to drop off means they all can act individually.

    I can change their AI behavior on the fly,

    but with the way you portrayed it, if a group of zombies spot you, the whole horde moves in unison towards you.

    This is good for zombies but Im not making zombies, lets use a different analogy, how about an army soldier.

    When they form a army, a leader is who sets the first goal to move, but at any point the player approaches an individual army soldier, they dont ALL jump on the player, its only the few that spot the player that do; Else, they continue moving along their path set by the leader

    when to many soldiers get close to each other, I want a box to spawn around them, count the number of soldiers.

    The box count is used to PICK from any zombie in the horde to act as the leader.

    When a leader is elected, the leader spawns another object, this object is a "CallToAction", it selects every soldier overlapping it ( its a large object ) and spawns yet another object which is a way point which sets the X and Y pos for their path finding to move towards.

    This part I can absolutely do, this is easy, its just the first step I can't do of making a box follow them to count everyone still in it.

    Any soldiers that don't hit the CallToAction are dropped off, they didnt make it, or they were too far away.

    Rereading my last post's order only made sense in my head, but yeah I can see how its confusing.

    The first formula you sent me was incredibly close to what I wanted, but the way it behaved upon further testing showed it wasn't quite what I was looking for, and on top of that,

    was not exactly what you said it did, here, let me post the original formula you made to see if I got anything confused:

    so for both X and y I did with adjustments for both obviously:

    AIGroup.x+300*((zombie.x-AIGroup.x)/sqrt((zombie.X-AIGroup.X)^2+(zombie.Y-AIGroup.Y)^2))

    so if I typed this correctly, the original formula said " hoard.x ", plus radius number,

    times Zombie.x subtracted by hoard.x,

    Then divide both by a square root of the power of 2, plus zombie.Y and hoard.Y to the power of 2.

    Upon further testing this seemed to have just worked like a lerp(), just longer written,

    It did have some weird effects to it that I can't quite explain where it looked like it was trying to get the position of ALL AI within that radius, but I imagine thats only because this effects all AI within that radius, so the box just teleports around trying to move over every single one.

    It did favor the first AI instance that initiated it though, so it usually hovered around it.

    Most of the solutions above either work but are impossible to add,

    Or don't work at all.

    I genuinely think its a misunderstanding thats stopping us from coming to a solid conclusion, this should be as simple as an expression, I just can't think of it.

    So instead of focusing on the whole goal I just need to know how you make a box follow multiple of the same sprites that are close to eachother.

  • First one is Cos or cosine of A and B, you typed it twice, had it been Cos and Sin it would give me a clockwise and counter clockwise view.

    Second one is asking for the number of zombies, which, I don't have.

    The point of what I'm trying to do is get that number which is why although I'm sure it would work, your adding the position of all zombies then dividing it by the number of them, I just don't have the number to begin that division.

    Also, I don't think Construct allows " ... ", I know some programming languages will take that as " so on and so forth ", but I don't think Construct has that operator.

    The website you showed me might be useful for future use, it looks like a generator which is super handy and might use for future projects, thank you for that, but unfortunately it looks like Ill have to keep looking.

    I have a solution under my belt which may work but it'll be quite complicated to create.

    But I dont want to do it if I know I'm absolutely sure it's possible to do this with a single expression, I think I'm close but perhaps we need extra brains to hop in on this thread to lend assistance.

    Thank you for your time.

  • Okay, yeah it looks like through further testing, "radius" isnt the radius the box will move adjacent, construct takes it as distance crossed each time the event is fired.

    In other words, if the event is fired once every 0.2 seconds, and its "radius" is 2 pixels, it will cross 2 pixels every 0.2 seconds.

    The goal I'm looking for is a box that follows the average of multiple AI instances, it is then used to count how many are in said box.

    The way it works in the gif is almost backwards in how I want it to work.

    A lead AI is not picked until everyone is counted. when a horde of AI is made, I.E they bunch up, a box surrounds them to count, then pick from that count,

    - this part I can do, as shown in the gif it counted two instances inside the box.

    But getting the box to follow multiple of the same instance probably means I need to approach this in another way.

    Thankfully I had just thought of something that may work, when a AI is close to another, I could store their positions in a library, if they get to far from each other they are removed from said library.

    Ill do that, unless you have an idea on how I could fix the above.

    I realize there was some confusion on what I wanted to do, sorry about that, but this should clarify.

  • i.gyazo.com/c619ad52533e9988e8ca43125b587ff3.gif

    Ok, so in this gif, it shows it working, but not for the same reasons as I hoped it would;

    You can see a box engulfing AI sprites ( which dont have any paths for testing purposes ),

    it moves to their position every 0.5 seconds, but it favors the first instance which initiated this event,

    which is why you can see it teleport back to the first AI that touched the view range of another.

    So its working, but how well it does this purely depends on the size of the container.

    It moves to the center of both AI instances its closest to within a radius of 100, I initially set this to the container's width since its height and width are even.

    But I quickly realized a circle does better at this than a square.

    But it isn't perfect, would there be any way to eliminate its preference for the first AI instance that spawned this container in so that it stops rocking back and forth?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The benefit of a horde is they all share the same calculated path of one instance.

    With the way I want to set it up, anyway; So the calculation is made once.

    1.) to pick the lead,

    2.) lead picks an end route to move on, spawns an area for other AI to call to action,

    if they don't make it, they are left behind;

    3.) And finally one more to disperse any AI within that field so that they aren't overlapping each other.

    Im confident I can do the other two, its just picking the lead that I figured Id have problems with.

    I also have a chunk system that will unrender and pause any AI not currently within proxy of the player, so lag would only be an issue if I hoarded every NPC up into one chunk and let them roam around.

    But Im sure I could fix that by limiting the number that can stay in one chunk at any given point in time.

  • Oh no for the path finding direction I already had something in mind for it,

    All I need the box for is just to count any AI within the horde, pick any that are touching it, then select one as a lead which will then forward a path finding direction for the rest, its critical for strategy and allows hordes to break apart slowly if they don't all make it to the lead's end position.

    But if this is just to move a sprite inbetween multiples of the same instance, then this is great help, I'll plug it in with some modifications and see if it works.

    I'll tell you how it went.

  • This forum post was made after discontinuing an old thread I realized is far more extensive than just the few questions I started out with.

    My goals are and will have to remain for this thread:

    1.) Use the Pathfinding behavior.

    2.) Use a custom LOS ( Line of Sight ) object ( In my case an invisible sprite ).

    3.) Work for multiples of the same instance, separately and individually.

    I'll start with my last question on that forum post, I'm working on an AI behavior or path finding type ( each type is separated as modules I can request ).

    The current one I'm working on is a horde behavior, and although I know how I wanna approach it, I lack the mathmatical know-how to make it work.

    How do you make a sprite follow inbetween two moving points of the same instance?

    Say I have 2 AI_Sprites, I want a huge box around them to use as a sprite counter, I need this box to be in the middle of all of them, and follow as they move until they break off from one-another.

    I feel like the solution for this is as simple as an action, perhaps something like "distance(AI(AI.IID = 1).X/Y, AI(AI.IID = 2).X/Y)"

    I used a similar formula in my first attempt which didn't work too well.

    My current solution is casting a ray between AI#1 and AI#2, and spawning a sprite in the middle of those two points, and removing it when I don't need it.

    This works, but I know this will lag after a couple hundred of them at once.

    But obviously I'm sure someone else knows better so let me know, it has to follow the conditions above is the only take away, families are also off the table.

  • Alright, Ill be closing this forum post and starting a new one, I formulated my own answers to most of the questions that I've asked but the help I got was helpful in deciding on what I should do,

    and gave me quite abit of bounce-back to enhance my thought process.

    My next forum post will be on the topic of pushing the path finding behavior, and likely will start with the last question I had on this forum post.

  • I find navigating the forum's page genuinely confusing,

    This is gonna be embarrassing but trying to find the " post new forum page " button just doesnt click in my head.

    So Ill post a question here since its critical for the next step of my AI.

    I am now working on a horde behavior, where AI move in unison.

    I need to spawn a sprite in between two of the same instance, and have it move with them, isolating it for those sprites is no longer an issue, I solved it and kinda mastered it.

    How do you spawn a sprite and have it move inbetween multiple of the same instance?

    Let me share a picture explaining what I wanna do:

    Until then Ill try to get this working myself, but any help is appreciated.

    If anyone new is reading this, I am using the same instance for my AI; I'm not changing this as its important for scaling of my game.

    I've already broken multiple barriers with my progress and don't plan on switching any time soon.