Is there in Haxe a "get object" function?

Hello! I want to get an object. Its not a child of an object. There is a “Get Child” function but my question is: How can I get a simple Object in Haxe?!

Hi, I see you didn’t specify with what property you wanted to find the object with, but a way to find an object through their name is (it’s with getChild but over the scene, idk if that you wanted to avoid),

        import iron.Scene;
        ....
		var anObject = Scene.active.getChild("object name");
		if (anObject != null)
			trace("success! object pos: " + anObject.transform.world.getLoc());

you can also find a Collection instead of an object, by the collection name:

        import iron.Scene;
        ....
		var aGroupOfObjects = Scene.active.getGroup("object collection");
		if (aGroupOfObjects != null)
			trace("success! Objects: " + aGroupOfObjects.length);
2 Likes

Omg I am so dumb! I already thought about that but didn’t try it out. Thank you so much!!

Hi, I created an entry in the wiki and a PR to add a new script example in /armory_examples to showcase how to use the functions and how to manually search objects in the scene that meet certain condition with recursion.
Feel free to test the functions I added, I did a few test just to be sure they work correctly but maybe I overlooked something.

1 Like

Currently it’s not straightforward to get an object! I use this one:

	this.target = iron.Scene.active.sceneParent.children.filter(function(f) {
		return f.name == "Character";
	})[0];

I should create PR to add findObject(name:string)

Well I would say getChild(string) is pretty straight forward if you ask me; but in this example there are a few other functions if you want to find an object with other than the name.

I have a bug in my code : getChild() works fine! Yes it’s pretty straight forward.