Check specific instances, not all of them together

0 favourites
  • 11 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Greetings!

    Just started working with Construct2, and I am loving it.

    I have sprite called "Fish".

    When I cast my "Hook", I pick a random instance of a fish (I have 5 at once) to go towards the hook at eat it. I also have an ability to "Recast", which destroys the hook.

    What I want, is for that Fish to go back to it's original position, and I have that part already figured out; I grab their starting position in an instance variable when they are created, so they know where to go.

    This is my event to tell if the fish is home or not:

    <img src="http://s7.postimage.org/64d6pnlmx/Event.png" border="0" />

    My problem is, the engine seems to only set this once all the fish meet those conditions. I want to set it on a per-Fish basis. If one fish meet these conditions, set "AtHome" = true for that fish.

    I've looked in the "How do I" page at the instance-specific guides, and I didn't see one that addressed this.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try adding a "For each (fish)" condition in there. It's a system condition

  • Also, if you want your fish to stop when within 10 pixels of it's origin, instead of the 4 conditions, you can do it with only 1 if you use the distance expression.

    Use "System: Compare two values", then input:

    distance(Fish.X, FishOriginX, Fish.Y, FishOriginY) < 10
  • Try adding a "For each (fish)" condition in there. It's a system condition

    EDIT:

    I think I tried that before and it didn't help. Here is what I've got now:

    <img src="http://s16.postimage.org/dv8l5550z/Event2.png" border="0" />

    Now the fish move to the hook, but when the hook gets destroyed by a recast, they just sit there.

    EDIT: Alright, I saw the problem, I inverted that distance check when I shouldn't have. When I fixed that, their behavior is the opposite. The Fish now constantly try and get to their origin, even if they do get there, unless they are going after a Hook.

    Also, if you want your fish to stop when within 10 pixels of it's origin, instead of the 4 conditions, you can do it with only 1 if you use the distance expression.

    Use "System: Compare two values", then input:

    distance(Fish.X, FishOriginX, Fish.Y, FishOriginY) < 10

    Ah, thanks! Much cleaner.

  • Hmm, do you think you could share your .capx through dropbox so we can have a look at the problem?

    It makes everything so much easier when we can see what happens and fiddle with it.

  • Hmm, do you think you could share your .capx through dropbox so we can have a look at the problem?

    It makes everything so much easier when we can see what happens and fiddle with it.

    Sure thing.

    dl.dropbox.com/u/88631007/MyProj.capx

  • When you click the recast button, this is where you need the "For each" loop, or a "Pick all fish" condition.

    Edited .capx: Nimble_Fishproblem.capx (r97)

  • When you click the recast button, this is where you need the "For each" loop, or a "Pick all fish" condition.

    Edited .capx: Nimble_Fishproblem.capx (r97)

    Ah, that makes sense, thank you much for taking a look. When you run it, do the "Fish" constantly move around their origin? I was trying to get them to stop moving once they reached their origin.

  • Yep, it's because I've given you the wrong order in the distance expression.

    It's supposed to be: distance(Fish.X, Fish.Y, Fish.OriginX, Fish.OriginY)

    The for each/pick all I added earlier is unecessary, but you'll need a loop above the distance checks, like 7Soul said. I've updated the .capx in my previous post. Sorry, I'm a bit tired xD

  • Great! Thank you, I learn the best from examples, so this is very helpful.

  • So I have two points. One is the origin I launch my "Bobber" Physics object. The other is where I clicked my mouse. The angle at which I launch the Bobber is constant. I need to calculate the force needed to launch the Bobber and have it hit the point where I clicked the mouse.

    Has anyone done this already, or could someone point me in the right direction?

    Thanks

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