This tutorial assumes that you understand the basics of entering Crayta’s CREATE mode and have some experience building levels.
In this tutorial, you will look at how you can use the Packages within Crayta to add playful Entities to our game.
Create Your Game
Navigate to CREATE mode in the Crayta menu and under CREATE A NEW GAME press A on EMPTY GAME.
Select STARTER: EMPTY GAME.
Name your new game “Robot Run Race” and press APPLY AND CONTINUE. Choose an image and press CREATE AND ENTER.
You should now see your empty Game. If any of that was confusing, head back to the Basic Workflow Tutorial which guides you through the process of creating and editing your own Game from the very beginning.
Otherwise if you are still with me, great! Read on!
Components are the basic building blocks of our game, and they include Sounds, Meshes, Scripts, Templates and Voxels. You can access the Components through your Library.
Open the Library by pressing Y.
If this is your first time using the Library, and you want a better overview, head back to the Basic Workflow Tutorial.
The Blank Game template has a range of basic Components that you can use to make your game idea a reality. However, there are many more available that have been created by Crayta makers and the Crayta Community. You can add these Components by visiting the Community tab and installing groups of Components which are called Packages.
When you install a new Package the Components are automatically added under the appropriate Library tab.
This tutorial will guide you through installing the RobotRunRace Package, which includes everything you need for the game you are about to make.
When you open the Library, your controller is now moving the highlight square in the Library menu.
Press Y to change tab to the Community tab.
Navigate the Community Packages and find the RobotRunRace Package.
With the Package highlighted, press A to install.
When installation is complete, the items from the Package will be added to the corresponding tab in the Library.
Adding Templates To Our Game
To return to the Library press Y.
Press R2 to change tab to the Templates tab. Here you should see three new Templates that were added by installing the RobotRunRace package.
In addition to the standard Player and User templates, we now also have RobotRunRace_Competitor, RobotRunRace_FinishLine and RobotRunRace_Racetrack. These templates feature custom functionality, and we can use them in lots of different ways.
To add RobotRunRace_Racetrack (the 3rd template in the list) to our Hotbar, highlight the Template by using the D-Pad in the Library window, and press A. The Library will disappear, and you will find that you now have a racetrack in your Hotbar.
You can move around to find a good spot, and rotate your racetrack by changing the direction you are facing with the Right Analog Stick. When you are happy with its position press R2 to place it. Remember, if you change your mind you can undo by pressing LEFT D-PAD.
Press RB to change to an empty Hotbar slot. This makes it easier to navigate and edit your world.
How exciting! You have a basic racetrack, with a start line. But you are the only competitor? It’s called Robot Run Race for a reason, right? Let’s get some robots involved.
Adding A Robot
Open your Library and select RobotRunRace_Competitor from the Templates. Press A to equip it.
Preview the game by pressing and holding D-PAD DOWN.
Tech Tip: Preview Often
There are two modes in the Crayta CREATE mode. Edit mode and Preview mode. To change between them, press DOWN on the D-PAD.
Edit mode: Here is where we can build our game world, add entities and change their properties. When you do anything in this mode it is saved. In this state, your game is not running, so entity behaviours such as movement won’t occur until we Preview or Run our game.
Preview mode: This is your game in action. Enter this mode to start any entity behaviours and test your game. When you do anything in this mode it is not saved.
Regularly Editing and Previewing your game follows the same process that game developers use when they are building a game. Always remember to Preview your game, to see how the changes you make in the Edit mode impact your gameplay.
Oh no! Come back Robot! You’re going in the wrong direction! You’re not supposed to wander off.
When you’ve spent enough time chasing the Robot hold D-PAD DOWN to return to the Editor.
Don’t panic, we can rectify the direction the Robot is running in easily, but first let’s take a look at how we can customise this part of the racing game.
Changing The Mesh
Press RB to select an empty hotbar slot.
Look at your Robot with your crosshair and an outline should highlight it with yellow.
With the Robot Competitor highlighted, press X to open the Entity Editor. You can open the Entity Editor for any Entity in your game.
Using the Entity Editor, we can change some of the properties of our Robot. To start with, we are going to make it a Wardrobe.
Use the D-PAD to navigate the Entity Editor menu. Highlight the meshAsset dropdown box and press A.
Scroll the list using the Left Analog stick. It’s in alphabetical order, so scroll down until you can see Wardrobe on the list. Then, use the D-PAD UP/DOWN to highlight Wardrobe. Press A to select.
Notice how the Robot has now magically transformed into a Wardrobe. This is because we have told Crayta that we want to use the Wardrobe Mesh with this Entity, instead of the Robot Mesh.
You can select any mesh from the meshAsset dropdown, and this can be a great way to experiment with different game themes. Maybe it’s bedroom furniture that’s racing, or different vehicles, it’s your choice.
And just for fun, close the Entity Editor by pressing B. Preview the game by pressing and holding D-PAD DOWN. Congratulations on making a “chase the wardrobe” game.
Return to the game, and return the Competitor to being a Robot instead of a Wardrobe (if you like).
Tech Tip: Entities, Properties And Behaviours
In this example our Entity Template is RobotRunRace_Competitor, but the actual Entity in the game is named robotRunRace_Competitor1. It is just one instance of RobotRunRace_Competitor. We can add as many instances of RobotRunRace_Competitor as we like.
Entities in Crayta have Properties.
Properties are information stored about the entity, such as its name, position and rotation. When we selected a new meshAsset for this entity we changed one of its properties.
If your robot was anything like mine, it ran in the completely wrong direction from the racetrack. Furthermore, it seems to be facing completely the wrong way. We can use the same technique we used to change the mesh to change the other properties of our entity in the Entity Editor and fix these mistakes too!
If your Robot is facing away from the racetrack then you need to follow these steps to make it face the correct direction.
Again, look at the Robot and press X to open the Entity Editor.
Use the D-PAD to navigate the Entity Editor. Highlight the middle box next to the label marked “rotation” and press A to begin editing this value.
You can use D-PAD RIGHT or LEFT to increase or decrease this number. When you change its value, you should find that the Robot starts to rotate.
Rotate the Robot to make sure it is facing in the direction it of the racetrack. It’s likely to be either 0, 90, 180 or 270.
Press B to stop editing the number and press B to close the Entity Editor.
Hold D-PAD DOWN once more to Preview your level.
Oh! It’s better, but it’s still not quite right. Finally, we need to make the Robot move in the direction its facing. To do this, we need to return to the Editor and open the Entity Editor one last time.
With the Entity Editor open, navigate to the boxes next to “speed”.
Tech Tip: Three Dimensions
3D games use three different numbers to determine a position in the world. A 3D coordinate system has values for LEFT and RIGHT (X), AWAY and TOWARDS (Y), UP and DOWN (Z).
Our “speed” values show how much our object will move in each of these directions each time the screen is updated (about 60 times per second, or 60 FPS).
By default, our CompetitorScript moves 100.0 units every frame on the X axis. Changing this value to -100.0 would move our entity in the opposite direction. Positive values move one way, negative numbers move the other.
Look at which way your Robot moves when you Preview the game. To move in the direction of our racetrack, we will need to have either 100 or -100 in one of the first two boxes, with the final box always 0. If it is already moving in the correct direction, note down what the current values are, and experiment with the following.
Try the following combinations of numbers. Consider what is happening each time, and choose the right one for your Robot. Remember, if something breaks or does not look right you can undo the last action with LEFT D-PAD.
|speed||100.0||0.0||0.0||Robot moves RIGHT|
To speed this up, you can also work it out logically.
If your Robot is moving LEFT/RIGHT compared to your racetrack then X will need to be 0.0, and Y will need to be either +100.0 or -100.0.
If your Robot is moving directly opposite away from your track then Y will need to be made negative (or positive if it was negative already).
Preview your game and make sure your Robot is travelling down the racetrack.
Success! Your Robot is now racing to the finish line.
Adding More Competitors
Now is a good opportunity to practice what you have done so far. Add more competitors to your game. You will need to adjust their mesh, rotation and speed properties to be the same as the first one. Repeat the steps from Adding A Robot if you want to follow the instructions again to remind yourself how to add competitors to the game.
Preview your level and make sure that you have some Robots, that all travel in the same direction in a race.
To make things more interesting we can change the speed of some of our Robots.
Open the Entity Editor and navigate to the CompetitorScript’s “speed” boxes.
Change your 100.000 to 300.000, or if it is -100.000 change it to -300.000 and you will see that the speed of the Robot increases.
Change this value for all of your robots and Preview your game. Notice that even though they are made with the same template, they can be made to move in different directions and different speeds (or behave slightly differently). This isn’t limited to the movement, as you will discover in the next tutorial.
The last thing we need to do is determine who won our race.
Open the Library and add the RobotRunRace_FinishLine to your Hotbar menu.
The FinishLine template includes a finish line, two flags and a Trigger Volume – an invisible box stretched between the two flags. The Trigger Volume has some special features.
One of your robots will enter this Trigger Volume, and a Script attached to it will tell you the name of the winning Entity. Make sure that the glowing blue trigger volume is the opposite side of the finish line to the robots, such as in this handy reference image.
Preview your game one more time.
Race your robots! Get to the start line, and race against them. First entity to the finish wins and…well…you’ll see what happens!
This tutorial was about taking you to the next level by adding packages and adjusting the properties of entities in your game. In this tutorial you have covered:
- Packages in Crayta’s CREATE mode
- Adding Templates to the game
- Changing an Entity’s mesh from a wardrobe to a robot
- Changing other Entity Properties including rotation and speed
You have the beginnings of a game, but Robot Run Race could go in whatever direction you choose (just like the wardrobe). You can use the same techniques to setup a race with your friends, racing against each other, or some ultrafast teapots? Some other things you could add might include:
- Adding a high-up area to spectate
- Adding more lanes, more competitors and space for players to race too
- Remove the racetrack and make an obstacle course for players to race through. The winner is the first one to the finish line!
You could also look at installing some other packages that would make for some compelling races. For example, try downloading the DancingCacti package, and use each of the Dancing Cacti to decorate your scene, or as obstacles for your racers!
Next Up: Action!
The next tutorial adds a lot more interactivity, and looks into templates that enable you to trigger events, make things explode and create puzzles for your players to solve.