Spawn a Ghost After Collecting A Coin

Home Forums Motive Q & A Spawn a Ghost After Collecting A Coin

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #3048


    This topic addresses the Ghost Hunter Unity Template. How can the system spawn a ghost after the user collects their first Wood Collectible?

    To accomplish this, you’ll want to use a new script and be sure that this script is launched (either through the debug settings screen, or launched in the Main script. This script will have a single frame.

    In this frame we are going to place a Location Task. This location task must have an action of Trap. Then under Action Items, assign one of the Ghosts in the Ghost Collectibles catalog.

    To trigger this frame when the user has collected a coin, we are going to place a precondition on the frame. At the top of the middle panel, click “Add Condition” and select “Inventory”. For Operator, select “greaterThanOrEqual”. For Count choose 1, and for collectible choose the “Wood” item in the “Ingredients” catalog.

    Now you just have to make sure this script is triggered somehow. When it runs, it will see that this precondition exists. If the precondition is not satisfied, it will wait until it is to play the resources for that frame.



    One more thing!

    We also need to choose a location for our Location Task. What we are going to do is use Dynamic Variables to select a location that is near to our player. Beside the Location option on Location Task, click the button so that it shows blue. This means this option is now Dynamic. Now beside the dropdown click new, this will create a new Dynamic Variable.

    Now you should see the Dynamic Variables screen. I’m not going to go into details here, I’m just going to show you how to select a nearby location. Click on the dropdown underneath the text “No default value set! If this setting is required, consider using a default”. Select “Choose Random Location”. Here are the settings you will want:

    • Min Distance: 10
    • Max Distance: 150
    • Count: 1
    • Name: anything you want

    You can play around with these settings. With these settings a random location will be created in the range of 10-150m and will have the title of the Name parameter.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.