dirtrider478 12 Posted December 28, 2020 Im working on a script and am wondering if once a gameobject is found and clicked on is there a way to check if that specific gameobject I just clicked on is still there.
SubCZ 284 Posted December 28, 2020 //Get object and its unique index GameObject obj = GameObjects.closest(objId); int objIndex = obj.getIndex(); ... //Check if obj is gone boolean objGone = GameObjects.closest(obj -> obj != null && obj.getID() == objId && obj.getIndex() == objIndex) == null; This is what I do if there's multiple game objects of the same type around. If it's the only one in the vicinity you can just leave out the index part
Pandemic 2817 Posted December 28, 2020 20 minutes ago, SubCZ said: //Get object and its unique index GameObject obj = GameObjects.closest(objId); int objIndex = obj.getIndex(); ... //Check if obj is gone boolean objGone = GameObjects.closest(obj -> obj != null && obj.getID() == objId && obj.getIndex() == objIndex) == null; This is what I do if there's multiple game objects of the same type around. If it's the only one in the vicinity you can just leave out the index part You could also use GameObject#exists: GameObject obj = GameObjects.closest("Whatever"); // Later on... if (obj.exists()) { // Object still exists } else { // Object doesn't exist }
abouhanafy87 5 Posted June 11, 2021 On 12/28/2020 at 9:24 PM, Pandemic said: You could also use GameObject#exists: GameObject obj = GameObjects.closest("Whatever"); // Later on... if (obj.exists()) { // Object still exists } else { // Object doesn't exist } What about if there's multiple game objects of the same type around
abouhanafy87 5 Posted June 11, 2021 There is 3 rocks i want to know when its exists and if i interacting one i can chech when its not exist but if other player interact another rock how can i know when it not exists
abouhanafy87 5 Posted June 16, 2021 On 12/28/2020 at 9:24 PM, Pandemic said: You could also use GameObject#exists: GameObject obj = GameObjects.closest("Whatever"); // Later on... if (obj.exists()) { // Object still exists } else { // Object doesn't exist } @Pandemic What about multiple game objects of the same type around
TheCloakdOne 389 Posted June 16, 2021 You could either get the rock based on its tile, or store each rock in a var each time you loop and check each var if it exists
abouhanafy87 5 Posted July 9, 2021 On 6/16/2021 at 12:15 PM, TheCloakdOne said: You could either get the rock based on its tile, or store each rock in a var each time you loop and check each var if it exists How can I store rock in var ?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.