Could someone tell me all the ways to end object with python please?I think it would be an interesting exercise.
obj.endObject()
That is one way.How would you end object by size?
Learn Python. Clue:
https://www.blender.org/api/blender_python_api_2_78a_release/bge.types.KX_GameObject.html#bge.types.KX_GameObject.worldScale
There are only three ways to end an object:
- Python (endObject)
- Logic brick end object
- End the entire scene.
You need to be more clear about what you want to do.
Sent from my SM-G920F using Tapatalk
Just wanted to see if there were other ways to end all object besides of a particular property.End all object of a particular property simultaneously?
When you endObjects with Python, I think it doesn’t happen until the end of the logic frame, if I’m wrong you can for example queue them and do so manually.
## Loop through all objects and end the one(s) without the property "propName" ##
## Run this once when needed, NOT every frame ##
SCENE = bge.logic.getCurrentScene()
for OBJ in SCENE.objects:
if OBJ.get("propName", "NOTFOUND") == "NOTFOUND":
OBJ.endObject()
## OR end objects when the property "propName" equals "END", can be run every frame, but not advised ##
for OBJ in SCENE.objects:
if OBJ.get("propName", "NOTFOUND") != "NOTFOUND":
if OBJ["propName"] == "END":
OBJ.endObject()
learn about loops, and know when to use them and when not too. this code is for example only, and will be very inefficient if not optimized for your code.
That worked.I will look up what is the best loop to use for large amounts of data.
I actually wanted to use this with my logic brick digging game.But i guess i could randomly spawn parented chunks
for the valuable minerals and food i could dig up.