Forum Discussion

Shards632's avatar
Shards632
Mentor
9 months ago

Weekly Creator Challenge #3: New Creators

New to Horizon Creator Challenge 

New Creator Challenge: Create an Interactive Gun!

Challenge Overview

This challenge introduces you to the basics of player interaction mechanics in Meta Horizon Worlds. 

You’ll learn how to:

  • Get events when players interact with objects
  • Fire projectiles from a launcher
  • Detect hits and play appropriate effects

Duration: Mar 10, 2025 - Mar 14, 2025

Estimated Time: Approx. 45 min.

Mentor: Shards632

Rewards:

  • Challenge Champion Badge 🏆
  • NEW! Challenge Trifecta Badge 🏆🏆🏆 after completing three challenges

Need Help?

 

  • Forum Support: I’ll be actively monitoring this thread during the Challenge duration to help you succeed
  • Live AMA: Join my Typescript for HZW on Tuesday, March 11th at 12 PM PST 

 

Challenge Steps:

1. Create Your Gun

  • The geometry doesn't have to be complicated! 
  • When I need a gun, I often just slap together a cylinder for the barrel and a soft cube for the handle that I get from the primitives in the build menu, and put them in a grouped entity. 
  • Or, if you want, you can grab a gun out of the asset library from the build menu.
  • The look of the gun isn't the important thing with this challenge, it's the interactivity. 
  • But go crazy if you have mad modeling skills and import something from Blender!

2. Add Interactive Components

  • Add a projectile launcher gizmo within the gun group, positioned at the muzzle of the gun.  
  • Add 'firing' sounds or particle effects gizmos to the group, for when the user shoots.
  • Add grab handles to the group, and adjust the grab anchor so that the avatar holds the gun by its grip/handle.
  • Pull a sound gizmo out of the library for an explosion sound, and a smoke poof particle effect gizmo. 

3. Create the Script

  • Create a script called "Gun" attached to the gun group.
  • Make a property for the projectile launcher, your launching sounds and particle effects, and your exploding sounds and particle effects.
  • Listen in preStart() to the entity for 'OnIndexTriggerDown' to find out when the player fires the gun.
  • Listen in preStart() to the launcher gizmo for 'OnProjectileHitWorld' for when the fired projectile hits something

4. Implement the Functionality

  • When the player fires the gun, tell the projectile launcher gizmo to launch a projectile. If you have sounds and particle effects in the gun for firing, play those now!
  • When the projectile launcher reports the projectile hit something, use the position information in the event to move the explosion sound particle effect to that location, and then tell them both to play!

5. Share your Creation

  • Post your published world link and a screenshot to earn your “Challenge Champion” badge!

Skills You’ll Develop: 

  • Connecting entity properties to a script
  • Connecting entity event code handlers for player and gizmo interactions
  • Playing sounds and particle effects

What You’ll Need:

Helpful Resources

Familiarize yourself with the APIs for the following:

How to Earn Your Badge

  1. Build a world with gun that shoots a projectile and creates explosion effects
  2. Publish your world
  3. Post to this thread with:
    • Your world link
    • A screenshot of your avatar with your gun
    • Brief feedback on your experience (difficulty level, what you learned, suggestions for future challenges)

P.S. Want more of a challenge? Try out the experienced creator challenge here.

 

10 Replies

  • Here we go! 

    World link: Javi's Weekly Creator Challenge 3 World 

     

    This was fun! I liked learning a bit more about TypeScript and how to use it, it still looks "weird" to me compared to other languages I've used but I'm slowly getting more used to it and the Horizon API. When you get that you have to have props which are then assigned to a variable and given a type, the actual code for the shooting/particles/sounds is very straightforward. 

    I decided to use my own gun from some primitives and it was really challenging to get the grab anchor right so it would be held "correctly" and shoot forward. After a lot of trial and error I got something that made sense, though I'm sure there's a better way of doing it than blindly changing angles and seeing if that improved anything! I also experienced a few crashes while working on this, though it doesn't take too long to restart the editor. That being said, having pre-made sounds and particles is really cool and it lets you have something that looks good really fast! 

    I've been able to test the world on mobile and it almost works perfectly - the pistol goes back to a default grab pose that makes aiming hard. I believe Focused Interaction Mode or something like this would fix this problem but I haven't looked into it and how to use it yet. That's something to do in the future! And in VR it works well!

    I think this was a great starting point and I'll be attempting the more advanced challenge now 🙂

    • Shards632's avatar
      Shards632
      Mentor

      Setting the grab anchor is almost always best done using the VR editor. There's really no substitute for being able to use your controllers to precisely position and rotate the grab point.
      If you make the avatar switch to the "Fire" animation pose name when they fire, it will put their arm straight out.
      Also, on desktop, if you press the right mouse button, it will go into 'aiming mode' and put your hand straight out, too.

  • That's a shame, I did all that without needing desktop editor although i did add a rounds and a reload 4 sounds 3vfx a player pop up with gun name, recoil that feels natural for caliber, haptics controller feedback when fired and separate launcher gizmo script controlling hit events on players and animated targets   .. I just don't have the funds for a computer at the moment!  But best believe I'm gonna be in desktop editor just like I said it's a shame But Rules are rules good luck everybody!!  

    • Shards632's avatar
      Shards632
      Mentor

      You can still submit your challenge entry if you did it all in the VR editor!

    • T00NAH's avatar
      T00NAH
      Member

      I hear you man. Glad to see that can do attitude. I can't wait to try out VR mode in DE. Best regards and stay with it, I may need some help down the road.

  • This challenge forced me accept where I am lacking (script wise) vs. what I envision. Eventually, I aim to be able to recreate this project without notes. Creating a CMI -blender asset- is also on the docket but my focus is mainly on learning how to bring functionality to a world and it's assets through scripting. 

    One change at a time...

    Thanks everyone.

    Wabbits??

    https://horizon.meta.com/world/553686094502168

    • Shards632's avatar
      Shards632
      Mentor

      If you've got something sort of working, submit it! Need a link to the world.  Don't worry about how the gun looks for this challenge. It's really about the interactive scripting.

  • I'm a little lost. Can someone please help. Here are my problems.
    #1-I can not make a copy of a tutorial world following the tutorial instructions because the "Advanced Tutorials shelf" does not exist for me in my headset or in desktop editor. 

    To create a copy of the Shooting Mechanics Tutorial sample world in Meta Horizon Worlds:
    1. In your headset, open the Create menu.
    2. Select the Tutorials tab.
    3. Browse the Advanced Tutorials shelf to locate the Simple Shooting Mechanics world.

    If I do not have the possibility of creating a world from a tutorial, can I just copy/clone the tutorial and rename it? Something tells me that it is not the same.

     

    #2- Where can i find the GunCore.ts and GunProjectile.ts scripts? I see them in the Simple Shooting tutorial but when I look at the scripts in the properties of the Projectile Launcher gizmo there are no scripts available. I have used the Script gizmo with code blocks but I am trying to do everything (except anchors) with the desktop editor. Am I supposed to copy paste the GunCore.ts and GunProjectile.ts typescript code from the tutorial and make my own scripts? Should I copy the folders and files from the scripts folder saved locally from the tutorial world. Is there a place to import scripts into the desktop editor? I feel like i'm missing something because this was easier with codeblocks. Thanks

    • Shards632's avatar
      Shards632
      Mentor

      There is no specific world to 'clone' for this challenge to start from.  There may be some info you can glean from the old 'shooting examples' tutorial, tho.  I am not sure what GunCore.ts or GunProjectile.ts are. Are those file you wrote? Or got from someone or somewhere else?