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...