Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 3: Finishing the Game Loop

Testing: Make Sure You Found an Entity

You don’t have access to this lesson

Please register or sign in to access the course content.

The type of object that we get back from getEntitiesByTag is an Array, which is a list of elements that you can access by number. To test that we are finding entities that have a matching tag, we’ll ask the console to tell us the name of the first entity in the list, which will be entity number 0.

  1. In the randomizeTreasure function, create an if-statement that checks that digSpots is not null.
  2. Inside the if-statement, log digSpots[0].name to the console.
  3. Call the randomizeTreasure function in the start function temporarily so that we can see it run when the game starts.
  4. Press Stop and Play and see what shows up in the Dev Tools Console.