How to... Studio?

I understand that Studio is still in beta, but I noticed that the documentation for scripting is somewhat lacking.

I was unable to find code examples for the following:

  1. How can I set an object as a child of the scene? I have an object that is currently a child of another, but I want to break this relationship so that the child becomes part of the root of the scene.
  2. How can I add a component at runtime? Specifically, I want to add a physics collider during runtime.
  3. How can I spawn an object with physics? For example, I would like to spawn a projectile.
  4. Is it possible to access face events for example by closing and opening the mouth?

Thank you for your help!

1 Like
  1. You can do world.setParent(eid, 0n) unparent an object
  1. You can add a component, specifically the collider like: Collider.set(world, eid, physicsProperties})
  1. You can call const newEntity = world.createEntity() to create a new entity. From there, you can use the above APIs to control the behaviors. You can also use ecs.physics.setLinearVelocity to give the projectile an initial velocity.

  2. The same events from this list are dispatched, for example world.events.addListener(world.events.globalId, 'facecontroller.mouthopened', handleMouthOpen) should work.

Hope this helps!

1 Like

Thank you so much @christoph_nia , this is what I’ve been looking for! The new Studio + ECS documentation :slight_smile:
It’s very confusing when you login to your dashboard and the β€˜documentation’ link shows only the legacy editor/apis.

I hope Niantic team makes this more visible in the near future.

Thanks for your feedback! I’ll forward it to the team so we can work on improving the docs.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.