====== Automatically attacked in player's area ====== ===== Finished product ===== {{ :developer_center:developer_editor:automatically_attacked_in_player_s_area.mp4 |}} ===== Trigger ===== To create this feature, we got to have 3 triggers * **Trigger 1:** will create a circle arround the player, it will move following player location * **Trigger 2:** will identify when **the player enters the creature's area** or **the creature's area enters the player's area**. * **Trigger 3:** will identify when **the player leaves the creature's area** or **the creature's area leaves the player's area**. * To identify in **//trigger 2//** and //**trigger 3**//, we're going to have a boolean variable. **Step 1 ** - Create the event to define the boolean (it's trigger 2) {{:developer_center:developer_editor:automatically_attacked_in_player_s_area_1.png?nolink|}} We are going to identify the player's area (it isn't an area created by hand; it is the player's location). Because, the player's handmade area can't be moved.  {{:developer_center:developer_editor:automatically_attacked_in_player_s_area2.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area3.png?nolink|}} **Step 2** - As mentioned above, we got to have a boolean variable to identify whether the creatures are insides the player's area. If yes, the boolean value will be true. If nothing, the boolean will keep false {{:developer_center:developer_editor:automatically_attacked_in_player_s_area5.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area6.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area7.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area8.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area9.png?nolink|}} **Step 3** - As above, we will create the event when player leaves that area {{:developer_center:developer_editor:automatically_attacked_in_player_s_area10.png?nolink|}} And we will copy area from trigger 1 to here: {{:developer_center:developer_editor:automatically_attacked_in_player_s_area11.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area12.png?nolink|}} **Step 4** - Because the cretures leave the area, and the area don't have any things now. Therefore, it will be //false// {{:developer_center:developer_editor:automatically_attacked_in_player_s_area13.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area14.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area15.png?nolink|}} **Step 5** - Then we will make the creatures get attack when entering. And we will create a loop for the trigger. It will repeat from //the player enters the map// to //they leave the map//. Therefore, we got to make it break for 1 second to reduce laggy and make the player get a good experience. {{:developer_center:developer_editor:automatically_attacked_in_player_s_area16.png?nolink|}} We are going to define the player's area with an effect, its size is 5 to fit will area 5 * 5 * 5 (we did above) {{:developer_center:developer_editor:automatically_attacked_in_player_s_area17.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area18.png?nolink|}} **Step 6** - Continue developing the loop, we will repeat when creature enters our area and breaking after they leave {{:developer_center:developer_editor:automatically_attacked_in_player_s_area20.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area21.png?nolink|}} {{:developer_center:developer_editor:automatically_attacked_in_player_s_area22.png?nolink|}} As mentioned above we need time to break the loop {{:developer_center:developer_editor:automatically_attacked_in_player_s_area23.png?nolink|}} Then we will make the creature takes damages and turns off takes damages of player's permissions {{ :developer_center:developer_editor:202408071419.mp4?800 |}} ---- If you have any questions about Developer Tools, feel free to join our official discord server [[https://discord.gg/NVRZHBChBt|Mini World Global DEV discord]]