Retrobot! A Brief Part of Internet History

Fun fact: this character goes back in time a bit. There are some things on the internet that are hard to forget. This robot was hard to forget one time too. He was a stock image mascot and has found his way around all over the internet. You could do a reverse search on TinEye.com using these images to see just what I’m talkin’ ’bout.

Main Prefabs

The robot prefabs can be found in the folder LB3D/Retrobot/Prefabs/Variants.

Animations

Included with the robot is a decent animation controller that should get you started. I’m aware that all games / apps are different, and usually the game designer will prefer to design their own character controller. You can safely remove this if you wish to create your own.

Please note: Many animations are included. However, this is a very simple character and can be animated in Unity. Teaching animation within the Unity editor is out of the scope of this documentation. Be sure to look into it using online tutorials if you are not already familiar with the subject.

Since this character floats and hovers, it was not necessary to provide root motion in the animations, as there is no foot-traction or other location-sensitive animations to keep track of.

Therefore, it is necessary to control the forward, backward, and lateral animations of the robot as he flies around.

To use the included animation controller, have a look at RetrobotController.cs

[code lang=”csharp”] using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RetrobotController : MonoBehaviour
{
///
/// Animator. Assigned in editor.
///
public Animator animator;

void Start()
{
animator = GetComponent();
animator.SetFloat("Motion_X", 0);
animator.SetFloat("Motion_Y", 0);
}

///
/// Plays a given animation. All actions are prefaced with "Do_" triggers in the animator.
///
///Action (one-shot animation) to be played.
public void DoAction(string action) {
animator.SetTrigger(action);
}

///
/// Sets the sideways motion state.
///
///Motion state: -1 to 1.
public void SetMotionXState(float value) {
animator.SetFloat("Motion_X", value);
}
///
/// Sets the forward / backward motion state.
///
///Forward / backward motion state. -1 to 1.
public void SetMotionYState(float value)
{
animator.SetFloat("Motion_Y";, value);
}

///
/// Sets the idle state (which occurs as forward or lateral motion states approach zero) ///
///
///Blends between 3 seperate motion states. 0 to 1.
public void SetIdleState(float value) {
animator.SetFloat("Idle_Pattern", value);
}

///
/// See documentation. https://lb3d.co/retrobot-unity-3d-game-asset-documentation/
/// Toggles fight mode.
///
///Toggles flight mode.
public void SetFightIdle(bool isFighting) {
animator.SetBool("Is_Fighting", isFighting);
}
}[/code]

One-Shot Animations

So, to play a one-shot animation, you could do:

[code lang=”csharp”]DoAction("Do_Giggle");[/code]

Or, from your own script, you may execute it in such a way:

[code lang=”csharp”]GetComponent().DoAction("Do_Giggle");[/code]

Here are some other cute actions included. 

[code lang=”csharp”]

// Included animations you can fire off with the DoAction method.
// See the complete list in the Animation Controller
// and in the animations folder, included within the asset.

DoAction("Do_Giggle"); //cute giggle.

DoAction("Do_Angry_Dramatic"); //becomes an angry drama queen.

DoAction("Do_Dissapointed_Slow_Shake"); //when you see silly questions posted in Unity forums.

DoAction("Do_Shock_And_Awe"); //your reaction when you first saw this asset on the Unity Store.

[/code]

Idle and Motion Animations

As mentioned above, the character controller does not use root motion. As your own script controls the locomotion and rotation of the character, you may employ these methods to get him to lean and animate accordingly:

[code lang=”csharp”] //when turning left or right:

SetMotionXState(0); //idle, no leaning

SetMotionXState(1); //leans to the right

SetMotionXState(-1); //leans to the left

[/code]

Above shows what you should utilize when he turns left or right in traveling.

Below shows varying degrees of forward or backward movement:

[code lang=”csharp”]

//when moving backward or forward:

SetMotionYState(0); //idle, no forward or backward animation

SetMotionYState(1); //leans forward

SetMotionYState(-1); //leans backward// or, for less extreme backward and forward movement…

SetMotionYState(0.5); //forward, just a little

SetMotionYState(-0.5); //backward, just a little[/code]

Be sure to check out the demo scene for how these things are implemented. Of special interest to you will be the items pictured below:

Retrobot Animation Controller

Retrobot Animation Controller

Animation Controller Blends, Idle and Motion States

Animation Controller Blends, Idle and Motion States

Other Idle States

There is a “Fight Idle” and other idle states. Fight Idle is the default ready to fight pose. The other idle blend is for slightly different idle animations, that differ in rate or air-float-depth.

[code lang=”csharp”]

SetFightIdle(true); // Retrobot assumes a fight pose in idle mode.

SetFightIdle(false); //Retrobot exits fight mode, and goes into normal idle.

[/code]

When the character is idling, he has 3 different idle animations, however you can blend between these from Zero to One.
Example:

[code lang=”csharp”] SetIdleState(0); // the basic idle, slower and less dramatic
SetIdleState(.5); // a more extreme idle, floating up and down a bit more…
SetIdleState(1); // a high energy idle, suggested for when character is wound up[/code]

NOTE: Please see the demo scene, and experiment with the built demo to get more acquainted with these. Pictured below:

Retrobot Demo Scene

Retrobot Demo Scene

RetroBot Icon Display

The included icons are from game-icons.net licensed under CC 3.0.

The RetroBot mascot has the ability to display signs, icons, logos, or other similar images. Some icons have been included for example, but the icon system is made for customize-ability for your own app or game, since the robot can be used for simple communications as a companion, guide, or presenter. For free icons, have a look at https://game-icons.net/.

In development, you may implement the icons (or your own iconic graphics) any way you wish. There is also a simple program provided on the character for changing icons and colors.

Assigning Icons Textures and Colors

On the RetroBot prefab, you can find a number of useful scripts attached (please note, you can remove and alter anything you wish for your own games or apps).

To assign unique icons (textures) and colors, you may utilize the RobotIconManager script pictured below:

Retrobot icon manager script, how to

Notice that both the icons and color options have foldouts, which you will use to assign the elements. Take note of the index values of each color / texture when you assign them.

Color foldout:

Unity editor color assignment - Retrobot Documentation

Texture foldout:

Unity editor texture assignment - Retrobot Documentation

To change established colors and icons programmatically, must first access and assign the RetrobotIconManager script the usual way via GetComponent() (we assume you are familiar with Unity C# in this case).

So, to give a one-liner as an example, you might use this to turn off the front icon:

[code lang=”csharp”] //turn off the front icon:
retroBot.GetComponent().ActivateFrontIcon(false);

// or to turn off the head icons…
retroBot.GetComponent().ActivateHeadIcons(false);[/code]

Change an icon example:

[code lang=”csharp”] retroBot.GetComponent().SetIconTexture(5);[/code]

Change an icon color example:

[code lang=”csharp”] retroBot.GetComponent().SetIconColor(4);[/code]

This is a simple script, so it will throw an error if you try to access an index that does not exist. It is expected that your program that you tie to the robot will use correct logic for your game.

To do away with the icons completely, simple toggle them off in the editor as such:

Turn off the icons

You can find example scripts in the scene. Look for the UseExample object. Open the script to see application. This script shows roughly how you’d implement the features into your own program.

Thruster Control

First off, if you want to create your own thruster effects, you may alter the robot by removing the thrusters in the prefab. Or simply disable them and remove the corresponding script from the prefab’s root object. Removing or disabling the thrusters may be necessary because particle effects can differ between rendering options in Unity. So, while the thrusters are useful in most circumstances, they might get in the way in some situations.

Remove or delete thrusters

An example of programmatically disabling (or enabling) the thrusters is as follows:

[code lang=”csharp”] //disable thrusters
retroBot.GetComponent().ActivateThruster(false);

//enable thrusters
retroBot.GetComponent().ActivateThruster(true);[/code]