FadeDown's Forum Posts

  • 6 posts
  • Capx : dropbox.com/s/lgqw6b0895ewzq4/sheepherder.78.capx

    Moments after the start of the capx you can see the problem, the sheep reaches the dog and instead of stopping or moving away from the dog (The latter more preferable than the former... but either would help!) the sheep sits there and proves Schrodingers' cat was an amateur.

    The sheep immediately trys to exist in both the state of toward the dog and away from the dog at the same time. I can't seem to get the sheep to pick one state or the other.

    I'm trying to get the sheep when "afraid" to move away from the herd object. Ergo, the Hdesire and the fear equation: (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) Which SHOULD increase the "fear" the closer the dog and sheep get to one another until Hdesire (the desire to herd up) is much smaller than the desire to run from the dog.

    With Hdesire at 10, when the dog closes to within 90 px of the sheep, it should switch to "fear" and stop "herd".

    Instead it sits and spins, even when well within the 90 px range.

    1. How do I fix that, force it into only one state, not both?

    Also: Adding a while in any of the three sheep functions crashes the game. All you get is a blank grey screen, or if it works, as soon as the event is triggered it locks up.

    2. I can't seem to get C2 to compare to global variables. If I try to declare fear to be an equation (100-(distance(dog.x,dog.y,sheep.x,sheep.y))) it won't store the value and defaults back to 0. If I set an On Start of Layout fear = (100-(distance(dog.x,dog.y,sheep.x,sheep.y))), it will not bring fear up as an option when I want to compare to variables as a system action.

  • FINALLY got a TRUE avoidance behavior out of the "herd" object.

    I had been using the "Set Angle To dog.Angle" as you suggested, but that was giving me bizare behavior when the dog and herd object were parallel, instead of moving away, you could actually move the herd object along side the dog, even if the dog changed direction so that at times the sheep were chasing the dog!

    After reading the angle commands a little more, I settled on:

    "Set Angle to (Angle(dog.X,dog.Y,herd.X,herd.Y)) degrees".

    This fixed the odd chasing the dog behavior and caused the herd to move away from the dog no matter how they were facing.

    I had tried:

    "Set Angle to (Angle(dog.X,dog.Y,herd.X,herd.Y)+180) degrees"

    at first, but the problem I ran into there was the herd always faced and moved towards the dog object. Useful if you are looking to cause the object to run AT the "avoider" but useless in my case.

    Thanks ArcadEd, your suggestions on Every Sheep and other pointers put me in the right direction!

  • Seems the nesting events was causing the problem. Dropped them all down to the same priority and it seems to be working better. Still can't quite get them to react to the dog object, they seem too focused on staying with the herd object. Makes sense a bit, but I have a feeling it will give me problems later when I try to include shedding behavior (splitting a sheep from the herd).

    Might try using a !dog.angle and !herd.angle...

  • <img src="http://i45.tinypic.com/6tjouq.gif" border="0" />

    This is what I have going on right now, and they all seem to be skating around like fools now.

    Have I not got the proper grasp of how C2 handles If-Else? I tried adding a system-else into the sub groups, but it kicks it out as "Not Valid Here"

    Edit: Just realized the text got pretty trashed by the image resize.

    4 - System for each sheep                            

        System distance(dog.x,dog.y,sheep.x,sheep.y) <= 30

        System Every Tick

       5 - System for each sheep

           System distance(herd.x,herd.y,sheep.x,sheep.y) >=30

           System Every Tick

          6 - System for each sheep

              System distance(herd.x,herd.y,sheep.x,sheep.y)

              System Every Tick

    Where

    4 sends the sheep at dog.angle by speed,

    5 sends the sheep at herd.x,herd.y by speed

    6 stops the sheep at the herd.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks. The set angle to dog.angle worked a treat. Had some difficulty with the file you posted, it tells me you are using R117, but I can only find R114. I found the spot in my file you were indicating and changed that.

    Capx file: Sheepherder.75 dropbox.com/s/eqkqj9z47320fru/sheepherder.75.capx

    Then I tried to fix the herding behavior. I made a few changes, removed the ram, added a "Herd" object and was trying to get the sheep all to move to the "Herd" object (pink circle, later to be made invisible, presently visible for testing) using an If-Else loop:

    If: dog near sheep, avoid dog (event 4)

    Else if sheep is not near herd, move to herd (event 5)

    Else stop. (event 6)

    Only I am running into the problem that all of the sheep are "Sheep" in the If-Else, so the sheep are satisfying all conditions of the IF-Else at the same time, one is close to the dog, one is close to the herd, one is far away, and one is ice-skating about like a fool.

    Is there a way (without calling each sheep "Sheep 1, Sheep 2, Sheep 3, Sheep 4") to force each sheep to go through the same If-Else? or have I implemented the If-Else improperly in C2?

  • Okay, I've been working on this all day, and I feel like I am getting close to a (clumbsy) solution that will work for me. First, the Capx:

    dropbox.com/s/cfrpehoswcvy8vq/sheepherder.capx

    What I am trying to do:

    I'm trying to write a "herding" game, where you give the dog commands, it runs out and basically chases around the sheep. The sheep should stay bunched up (in a little herd) but should move away from the dog. They tend to move away as a group, but if the dog gets too close (buzzes the sheep) they will eventually split off.

    Right now, I am JUST trying to get a working herd of four sheep to clump together, move together, and flee the dog. I have them clumping (sort of) around the "ram" object and following the ram, and the ram is supposed to be fleeing the dog.

    Preferably, the ram would move away from the dog more or less directly away. IE: if the dog runs to the right at the sheep, the sheep run away right. If the dog runs right and up from below and left, the sheep should run right and up as well.

    Basically, the sheep need to avoid the dog. I can get them to FOLLOW the dog all day long using "Set angle toward dog.X,dog.Y" and a setting a speed, but inverting the equation with "Set angle toward -dog.X,-dog.Y" causes the sheep to run in the same direction every time.

    I tried the Boids flocking behavior addon earlier this evening, and ran into problems with that, also. The sheep wound up stacking on top of one another, or when I finally got them to behave like solid objects would push the ram all over the screen, then also they blocked the ram from moving if the dog got close.

    Any assistance or suggestions on this would be helpful.

  • 6 posts