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 that come with 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 select Empty Games.
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 on controller or L on keyboard.
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 asset library you will need to switch to the community tab by pressing Y on the controller or selecting the heading Community with the mouse cursor.
Navigate the Community Packages and find the RobotRunRace Package.
Using Filters and Tags
Trying to find packages can be hard work, but you can use the filter to search for a specific package name. Try searching for RobotRunRace to easily find the package you want.
Better yet you can use tags to look for a specific group of items if you have a specific theme in mind!
With the Package highlighted, press A on controller or simply click with the left-button on a mouse 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 on controller or L on keyboard.
Press R2 to change tab on controller or select the heading with the mouse to access 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 to our Hotbar, highlight the Template by using the D-Pad in the Library window, and press A or select it with the mouse. 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 your character is facing with the Right Analog Stick on a controller or using your mouse to look around. When you are happy with its position press R2 on controller or left-click with the mouse to place it. Remember, if you change your mind you can undo by pressing Left D-pad on controller or Ctrl+Z on keyboard.
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. Equip the robot in the same way as the race track then place the robot on one of the starting lines. Remember, you can change the orientation of the robot by moving your character around the mesh.
Preview the game by pressing and holding the menu button on controller or pressing F5 on keyboard.
Tech Tip: Preview Often
There are two modes in the Crayta CREATE mode. Edit mode and Preview mode. To change between them, press and hold the menu button on controller or pressing F5 on keyboard.
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 not supposed to wander off.
When you’ve spent enough time chasing the Robot exit the preview by following the step you initially used to enter preview mode.
Don’t panic if your robot is moving incorrectly, we can rectify these issues easily, but first let’s take a look at how we can customise this part of the racing game.
Changing The Mesh
On a controller press RB to select an empty hotbar slot.
Look at your Robot with your crosshair and you should see a yellow outline; this means that the robot is your active entity.
With the Robot Competitor highlighted, press X on controller or E on keyboard 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.
On controller use the D-Pad to navigate the Entity Editor menu. Highlight the Mesh Asset dropdown box and press A. On Keyboard and Mouse you can simply select the Mesh Asset dropdown by clicking on it.
Scroll the list of meshes using the Left Analog stick on controller or the scroll-wheel on mouse . It’s in alphabetical order, so scroll until you can see Wardrobe on the list. Then, highlight Wardrobe by pressing A on controller or simply select it with your mouse to accept your selection.
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 Mesh Asset 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 on controller or selecting the cross icon with your mouse. Preview the game and congratulate yourself for making a “chase the wardrobe” game.
Return to the game, and follow the steps above to swap the Competitor back 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 may have run in the completely wrong direction from the racetrack or started facing 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. If not, feel free to play about with the orientation by following along or scroll down to the next section!
Look at the Robot and press X on controller or E on keyboard to open the Entity Editor.
On controller use the D-Pad to navigate the Entity Editor. Highlight the middle box next to the label marked “rotation” and press A on controller or you can select the middle box with the mouse cursor.
You can use D-Pad Right or Left on controller or and type in a value on keyboard to begin editing this value. 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.
On controller press B to stop editing the number and press B to close the Entity Editor. On Keyboard or Mouse you can simply select enter to confirm and select the cross icon to close it.
Once more you need to preview your level.
On previewing you may find that the robot faces the right way but it moves in another direction. To fix this, we need to return to the Editor and open the Entity Editor one last time. If not it’s still worth following along to see how to change both the speed and direction of the Robot.
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. The Crayta 3D coordinate system has values for LEFT and RIGHT (X), BACK and FORWARDS (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 (Typically 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 zero (Unless you want your Robot to go to space.) 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. I’ve added my own notes, but it’s possibly your Robot may handle differently. Remember, if something breaks or does not look right you can undo the last action with Left D-Pad on controller or Ctrl+Z on keyboard.
|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 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. If you changed the mesh, then you may want to switch that as well.
Preview your level and make sure all the robots are facing and travel in the same direction.
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.
On one Robot 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.
Based on the above, change this value for all of your robots to a slightly different value 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.