So I am making a tower defense. How do I make so when you click it places it down.
So I am making a tower defense. How do I make so when you click it places it down.
There is a few different ways, but I assume you would want to use the Grid Feature.
I.e. Click somewhere within a grid to drop a turret.
First you would need an always event with the following for a 640x480 Game Screen size. Link a 40x40 square to the mouse movement ( Border ).
1) ( XMouse / 40 ) * 40
2) ( YMouse / 40 ) * 40
This makes a 40x40 Grid ( Adjust the 40 as needed for the screen size you are using.)
Next you will need the Object you wish to place.
Typically I make a duplicate of whatever I want to place that has no animation. Basically a Static Object ( Clickable ) and the Actual Object ( Place able )
Once you have them ready. You would make it so when you click on the Static Object, it turns Flag 0 on.
Then when you click on the map, The Place able object is created in the location you clicked positioned at the 40x40 square border and Flag 0 for the Static object is turned off.
This will create 1 turret at the location you clicked on the map.
You can also use qualifiers so that you can't place one turret on top of another. This can also be used to keep turrets from being placed on roads, trees, water, etc...
I.E. User clicks on another turret while flag 0 is on. Nothing happens or an error sound could be played.
The Qualifier is not over lapping the qualifier, allow placement!
Another way is to use the Static Object as a controller without Flags.
Here is a quick little .MFA using Direction of the Static Object to control Placement.
LINK: https://drive.google.com/file/d/1t_V...usp=share_link