Group issue in Typescript

Honestly cospaces documentation is not good. This is for education so there should be examples for javascript. I don’t want to use just coblocks. Also, when I try to say “Scene.getItem(example) as Group” it tells me I can’t even though when I click with two fingers and click coding it tells me to do that. What? excuse me? Why do I have to do toArray().foreach(item=>{}) just to move a group?

Hi @zan,

I encourage you to communicate on this forum in a way that’s respectful, in a way you would talk to someone if they standing in front of you, and in a way that you would like to be talked to.

Reframing your post, I can see you’d like to see more examples of scripting in the documentation, and that you have found a bug in the Scripting API (@Stefan) or UI, which is not uncommon, as the CoSpaces developers often update the API, and humans make mistakes.

You can be supportive by pointing out the issue you’re having, clearly, and without the attitude/dramatics.

Here’s a solution: remove “as Group” and it will work fine. I found this simply by trying it out.

Hope this helps.

Geoff @ TechLeap

Sorry. Also I know that but the real purpose of my question was why if you click on an object with two fingers and click coding, under the id and enable in coblocks option, it literally gives you a copy and paste to “Scene.getitem() as group” when group doesn’t even exist… Who do I @ to point this out? Also I think there should be an easier way to access children of groups then “.byName()” and “.forEach(){}” - unless there is one that I don’t know of, but I spent a while looking.

It depends on what you want to do with the children. This code moves a group of unicorns:

const unicorns = Scene.getItem("uJPNhMm3"); // Group
unicorns.transition.moveBy(new Vector3(0,12,0),4);