03-24-2025 07:31 AM - edited 03-24-2025 10:07 AM
This challenge introduces you to simple asset spawning using the desktop editor and Typescript.
You’ll learn how to:
Duration: Mar 24, 2025 - Mar 28, 2025
Estimated Time: 30-45 Minutes
Mentor: SeeingBlue
Rewards:
P.S. Want more of a challenge? Try out the Experienced Creator Challenge: World Streaming.
Join my AMA: Asset Spawning and World Streaming on 3/25/2025 @ 12PM PST. Register here
03-24-2025 09:33 PM
I see how I can access the spawned Entity using this.world.spawnAsset since it returns a Promise<Entity[]>. But what if I use the hz.SpawnController? It only seems to return Promise<void> for its methods. I would like to be able to get the spawned Entity and add attributes (such as physics, tags, scripts?, etc.).
03-25-2025 05:18 AM - edited 03-25-2025 05:18 AM
According to the Creator Manual, after the promise is received you have to use controller.rootEntities to receive the entity array. Hope that helps.
03-27-2025 06:27 PM
Added my baseball as an asset from the batting cage tutorial. While spawning, I learned that you can't do that from a local script. To modify the asset, I removed the ball script that was originally attached (it did the pseudo-spawn thing like in the tutorial. somewhere along the way, I lost the ability to actually hit the ball (during the tutorial, I got a nice "crack of the bat" sound effect and had to put colliders up to stop the ball from falling off the edge of the world. The spawn works like this: when you grab the bat, the ball will spawn from an offset from the player's position (not yet rotation). When you let go of the bat, the ball is deleted. I will keep working to get back the capability to actually hit the ball and will eventually add some graphics to document hits and misses.
I am glad this challenge was put out: I can see spawning items in many situations.
https://horizon.meta.com/world/570922982775205
03-31-2025 02:25 PM
Great job on this. You are correct, local scripts cannot access PPVs or handle spawning/despawning. You may have to explore transferring ownership of the ball and bat to the player if you haven't already.
04-15-2025 09:10 AM
hello Why does my script have a problem with horizon/core? 😓
04-15-2025 09:48 AM
It would suggest it doesn't have access to the definition file, which is created on your computer by default when you join a world and create a new script. Is this SimpleSpawning file being run from a world folder created by the desktop editor, or just in a separate folder you created?
04-15-2025 10:55 AM
avec l éditeur de bureau ,j’ai fait une pause et je l’ai rallumé, et maintenant ça marche. Les Mystères de l informatique😁😂
Merci de vos réponses.