tarek2's Recent Forum Activity

  • Do you mean on the web?

    You can use the Browser plugging "Invoke Download"

    Exporting to Nwjs etc..?

    You can use "Write Binary" in the Nwjs plugin

  • You need to share a small example so someone can investigate it and help you as it's not clear what is happening here.

    In general (Bound to Layout or Dragg) it shouldn't interfere to destroy an object as long both are overlapping.

    It's hard to say without looking at an example.

  • MessMess

    Families were created to solve many problems, like Picking and treating many different objects as a single object to simplify the code and the Picking and the number of events that you would normally need.

    In your case, it's a perfectly valid solution and simple, as that is what it was designed for, you just need to follow the advice that was given which is to put the objects in a separate Family that you will just use for clickable objects so you shouldn't have any problem if you followed the advice.

    4-You could put them in a family and filter them

    Put all your click-able objects into a family, then you can setup your events like:

    More info about Families:

    https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/objects/families?utm_campaign=C3Editor&utm_source=browser&utm_medium=r391&utm_term=OpenManualLink&utm_content=ProjectBar-FamiliesHelp

    There are no restrictions on how many families you can create in the c3 paid version.

    Are there more solutions?

    Yes

    Do you have to use families?

    Not necessary, you can use the method you like the most and which it resolves your issue in the most simplistic and logical manner. So Families is just one of them. There are other solutions without families.

    It would be an instance variable at the family level, also called a family instance variable, so on the family object Towers you can add an instance variable 'stamped' for example. Then in a general event (order doesn't matter), you can add 'on mouse click release' and 'Towers.stamped=0', set Towers.stamped to 1 (0 is default).

    Another way to do the same functionality without using mouse click is to have an event 'Family Towers on created' - wait 0.1 seconds, set Towers.stamped to 1.

    Then returning to your original event for rotating, you add a condition 'Towers.stamped=1', means it won't be rotated at the same time it is created but on second click it is possible. You can then remove the black square from the family also.

    None of your solutions solved the problems he had lol

    Honestly, they dont make any sense if you look from the perspective of the context that he needs to solve. ))

    The Issues he was trying to solve:

    He has two totally different and independent events:

    1-If you click any obstacle that has no tower --------> Spawn a Turn object which I assume is a (Tower)

    2-If you click in a Tower --------> Rotate the tower 90 degrees clockwise (Probably to fire enemies at different angles)

    It would be an instance variable at the family level, also called a family instance variable, so on the family object Towers you can add an instance variable 'stamped' for example. Then in a general event (order doesn't matter), you can add 'on mouse click release' and 'Towers.stamped=0', set Towers.stamped to 1 (0 is default).

    There are many issues with this solution:

    -You dont pick correctly the target "Tower" which you need to use the "On Mouse Click On Tower" to know to who you need to apply the action Rotate, so your events are not clear as to which Towers are applying the Rotations. Because without Clicking the Tower you can never know to which tower you need to rotate.

    -"On Mouse Release"

    Is gonna fire the Rotate Events and conditions checks each time a "Mouse-Click" is released.

    He doesn't need that as he wants instead to just rotate the Tower explicitly when you touch it, not every time you release the Mouse click.

    Another way to do the same functionality without using mouse click is to have an event 'Family Towers on created' - wait 0.1 seconds, set Towers.stamped to 1.

    The same issue:

    -The Picking is wrong as it doesn't need to rotate the objects that are created, just the ones you select with "On Mouse Click On Tower"

    therefore there is no way to change this condition so you have to use "On Mouse Click On Tower" and you have to make sure that both triggers (Towers & Obstacle) dont trigger at the same time.

    Then returning to your original event for rotating, you add a condition 'Towers.stamped=1', means it won't be rotated at the same time it is created but on second click it is possible. You can then remove the black square from the family also.

    -This is just personal but:

    I would recommend you always run your events under a Trigger whenever you have the opportunity, which in this case we have under "On Mouse Click On Tower"

    [b]-"On Mouse Click On Tower": [/b]
    Will only trigger on user input and it will run the events only once
    
    [b]-'Towers.stamped=1',[/b]
    This checks "every tick" 
    Every Tower if (is = 1) 
    Unnecessary just to rotate when you can do the events under a trigger which will run only "On triggered" and it will run the action to just the clicked tower.
    

    This avoids scenarios such as:

    Imagine you have a big layout with hundreds of Towers, it will:

    Check "every tick"

    Every Tower if (is = 1)

    Wasting resources is unnecessary just to make a simple rotation.

    Benefits of adding the actions under a Trigger:

    -You keep all your actions under just one event which makes it easy to manage instead of having separate events and conditions. Also, it makes it easier to debug when you have a bug as you have everything under one event.

    -Save resources

    -Avoid unnecessary waits, as if you keep adding them in any trivial matter just to solve simple issues such as this which doesn't need any waits you could end up in the future in a big messy code and potential bugs when you try to add new features etc... Which could be hard to track.

    Alternatives Solutions:

    If for any reason you dont want to use families. Remove the obstacle from the family.

    There are many ways you could archive this:

    1-Just add a condition blocker to the obstacle:

    Note:

    Make sure that the Tower is at least 1 pixel smaller than the obstacle to work, otherwise if both are the same size then it will trigger true if it overlaps neighbours Towers on different tiles, so by setting the tower to 1 pixel smaller it avoids false triggers from the neighbours.

    An alternative you could just make the Tower collision box 1 pixel smaller if you need to keep both (obstacle & Tower) the same size.

    2-You could keep track of the obstacles that have a Tower by adding a boolean like for example "Has_Tower"

    -On your event that you spawn the Tower --------> Set Obstacle.Has_Tower = True

    Then these events:

    There are probably many more ways, but in short, don't be scared to use families as they are a very powerful feature in Construct that you will need to do from advanced things to simplify your events etc...

  • Like this:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Really appreciate your patience (I'm used to more traditional programming and I guess I haven't fully grasped events yet).

    Anyway, I think I added the check for the ObjectTypeName correctly (see image):

    But, where the heck does the Else go? I can't even find an else statement in the events sheet.

    On family Clicked:
    Pick Top Instance:
    ---Subevent: System Compare: Family.ObjectTypeName = Obstacle:----> Create Turn
    ---Subevent: Else: Rotate 90
    

    This "-----" below means a subevent.

  • I feel very dumb and I'm not sure what I'm doing wrong now.

    No worries there are no dumb questions, especially when you are new to Construct. Ask any questions you need.

    You need to put the obstacle in the family swell and then make just 1 one click event then you can compare which object it is and do your actions accordingly:

    Example:

    On family Clicked:
    Pick Top Instance:
    -----System Compare: Family.ObjectTypeName = Obstacle:----> Create Turn
    -----Else: Rotate 90
    
  • Families seems like the best solution, but I must be doing something wrong.

    I created a family called towers and put all my tower objects into it.

    This is my event:

    But now, when I click on it, every instance of "Turn" is rotating, not just the one I clicked on.

    Any idea, what I am doing wrong?

    You are applying the Action to the "Turn" object instead of the one that you pick in the Towers family, that's why it applies the action to all the Turn objects because there was none picked on the conditions therefore it applies the action to all instances of Turn.

    Select the "Towers" family instead to apply the rotate action

  • One issue that I find very annoying with the video player is that you cannot set a thumbnail from the video frames itself, so the video will be invisible until you start playing it. This forces you to create a separate image to use as an icon otherwise the user will not see that there is a video to play.

    I tried to do a video gallery a few times and ended up having to create an icon image for each video which is time-consuming and uses extra Memory RAM.

    It would be nice if they could add to the video plugin the option to set a Thumbnail from a video frame by setting a specific time in the video timeline.

    Here is one example of the issue:

    https://www.dropbox.com/scl/fi/ou2ri5oemt6qh40evv5p5/Video-Player.c3p?rlkey=ut5oi4g0ynj6tvhnzkqh4s6b7&dl=0

    If you Run the project you dont notice that there are two videos to play unless you set "Autoplay to yes" which is not ideal having all your videos playing at the start.

    or

    Alternatively, you need to add thumbnail images to see that there are two videos to play.

  • Hi

    I haven't used the Rexrainbow Matcher addon but in general, you can add new lines in construct by using the expression:

    newline

    If you want to add it after a string text then you add the &

    Example:

    "X" & newline & "Y"
    

    The results will be:

    X

    Y

  • 1-You could add a second condition is visible:

    On touched object

    Object isVisible

    2-You can set the other layer interactive to false if the objects are on different layers

    3-If Both objects are on the same object type you could use system "Pick top instance"

    4-You could put them in a family and filter them

  • Sorry, I forgot to remove a local variable that is not needed, as originally I was gonna put everything under "on Tile clicked" by using Local Variables but after I switched to functions and I forgot to remove that variable.

    I updated my last link.

  • Yes, thank you very much, this is exactly what I needed! +100 to karma ))

    Np

    Glad it was helpful ))

tarek2's avatar

tarek2

Early Adopter

Member since 26 Jan, 2016

Twitter
tarek2 has 12 followers

Trophy Case

  • 8-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • x5
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

15/44
How to earn trophies