pandabear7413's Recent Forum Activity

  • because there's only one instance of the function object

    "function object"? As I understand it, functions aren't objects and they don't have instances. Instead, they're events. Per the docs:

    Functions are special kinds of events that can be called from actions. https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/events/functions

    But maybe I'm misunderstanding what you're saying...?

  • Thanks for the reply. I'm trying to understand what exactly are the rules for running functions against a picked set of objects.

    Actions always try to apply to one object. Without a condition, an action has no way to pick an object, so it applies to all objects.

    Per my 2nd post above, I believe the rule is: object-specific actions are run once for each object picked, non-object-specific actions run only once per event (regardless of how many objects are picked).

    But when you add a condition, the action gets some instruction. If the condition could be satisfied by multiple objects, it picks one at random. Adding "for each" forces the actions to repeat for each object that satisfies it.

    So in your top event, the function is only picking one random Sprite uid. If you add a "for each sprite" on that subevent, it should call the function three times.

    Re: "random", I'm guessing C3 doesn't pick objects at random. There are probably some rules it follows for to decide which object UID to pass to the function - e.g., it picks the object with the smallest UID. That's what my code does every time, it picks the Sprite with the smallest UID.

  • Let me take a stab at answering my own question: It's because calling the "move" function is not an object-specific action. Only object-specific actions (e.g., Sprite set animation) are called once per picked object. Actions that are not object-specific are only called once per event, regardless of how many objects are picked.

    Is this accurate?

  • Here’s my code. I have 3 Sprite objects, and all have state set to “good”. When I press the right arrow, “count” is set to 3 (i.e., 3 sprites are picked), but the “move” function is only called once with the UID of the first sprite create, so only that sprite moves.

    Can someone please explain to me why this code only calls the "move" function once, and not once for each object picked? Per the C3 docs: Another way to think about an event is "If all conditions are met then run actions on the instances meeting the conditions". https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/events/how-events-work

    I understand that adding a ‘for each Sprite’ condition before calling “move” will get all sprites to move, but I’m trying to understand why this is necessary.

    Thanks

  • dop2000 I get so pumped when I see you're responding to one of my questions, you are always spot on with your answers! This is exactly what I was looking for, and that tutorial from Ashley is gold. Thanks again!

  • Some context: I have a family called enemies, which is pretty established, and I wanted to create a new enemy type called Wolf. Wolf is very different from the rest of the existing enemies, which are mostly human-based, so I needed to develop lots of new code to control and animate Wolf. But in the end I still want Wolf to be a member of the enemies family as there’s common enemies code that will apply to Wolf.

    I wanted to avoid the existing enemies family code being called on Wolf during prototyping, as it would potentially throw everything off in the game and make prototyping a lot harder. So I chose to create a standalone object called Wolf to prototype. Even though it’s not part of the enemies family, Wolf has several identical behaviors and instance variables, like ‘health’ and ‘hitStrength’, and the Platform behavior.

    Now that I’ve got Wolf working (yay!), I want to add it to the enemies family. But because it has the same instance variable names as enemies, I need to change them before C3 will let me add Wolf to the enemies family. I expect this will involve a) changing the names of those IV’s in Wolf (e.g., change ‘health’ to ‘health2’), b) adding Wolf to enemies, c) changing the Wolf logic to use the IV’s from enemies (e.g., change anything referencing ‘health2’ to ‘health’), and then d) deleting the Wolf-specific IV’s ((e.g., ‘health2’). I’m probably going to need to do something similar with the common behaviors as well.

    This is just an example but it’s making me think there may be a better way.

    My question is, what’s a good way to plan for such ‘merges’ of code, and is there something I should have done differently? C3’s editing logic is great because it checks for errors caused by duplicate IV and Platform names, and I wish there was an easier way to do this merge without having to pick through my code. Any suggestions?

  • Thanks R0J0hound for the suggestion, similar to what I was thinking - but better!

    I was curious if there was a way to use elegant pick logic to do this in a 1- or 2-line event. I've seen some beautiful code suggestions in these forums that I never would have come up with, mainly because my brain just doesn't think that way.

  • Ctrl + P

    I always used ctrl+v to paste but I figured I'd try this ctrl+p suggestion. It spawned 10+ Chrome windows and tried to print the contents. After closing them all I saw that my 20+ tabs in C3 were out of order. Fun.

    So yeah use ctrl+v to paste...

  • I have 2 object types, A and B, and both have an instance variable called matchID.

    At certain points in the game, every B instance should be destroyed if there isn't an A instance whose matchID equals B.matchID.

    Here’s my pseudocode:

    - IF there is a B instance whose matchID instance variable does not equal the matchID instance variable of any A instances, THEN Destroy B instance

    What’s a clean way to implement this with C3? I'm probably overthinking this but I cant come up with something elegant.

    Thanks

  • I figured it was something browser-specific, thanks Ashley for the confirmation and additional detail.

  • luckyrawatlucky's insanely good Theme Dark seems to have the perfect solution for this already...

    You're not kidding, I just installed the theme, the hidden X feature is great and the theme itself is fantastic. Thanks for the tip and to luckyrawatlucky for the theme!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Update: I saved my project to a single file and opened it with FF, and FF is MUCH faster than Chrome, maybe even a touch faster than Chrome was before it started having issues. I then opened that same file with Chrome to see if it's a file-vs-folder thing, but Chrome is still as slow as it is when I open the local project folder.

pandabear7413's avatar

pandabear7413

Member since 9 May, 2021

None one is following pandabear7413 yet!

Trophy Case

  • 5-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • x4
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • Email Verified

Progress

12/44
How to earn trophies