Ruby’s Adventure: 2d Beginner Official Thread

Alongside our brand new Learn platform, Unity’s Learn Content team have released a new 2D beginner project. This project is a great way to introduce you to beginner code, tilemapper, sprites, collectibles, quest controllers and more, all wrapped up in this RPG style game tutorial.

Step by step, use the 2D assets provided to help Ruby fix her robot friends. The written lessons have editor screenshots and gifs to help you learn how to re-create the game.
For the first time we’ve released two versions of our project. You can find the tutorial project where you build the game from scratch, but also the completed project where you can see how we’ve made the demo level and play the game in the editor.

Find the tutorial on the Unity Learn site here

Download the Tutorial Project here

Download the Complete Project here

4 Likes

Hi,

I am going through this tutorial and really liking it so far.

I have found a bug in Part 9 Sprite Animation.

In section 5 Setting animation for the main character you have the following bug in the Update() method:

// The following is a bug the parameter is actually "Look X" and "Look Y"
animator.SetFloat("Move X", lookDirection.x);
animator.SetFloat("Move Y", lookDirection.y);

It should actually be the following:

animator.SetFloat("Look X", lookDirection.x); 
animator.SetFloat("Look Y", lookDirection.y);

Anyway just thought I would point that out as some new users may not be able to easily debug the problem.

Thanks for the learning tutorials, really great way to get started with Unity.

Regards,
Anthony

12 Likes

Found another bug in part 10 World interactions - Projectiles in Section 2 Launching the projectiles

void Launch()
{
    GameObject projectileObject = Instantiate(projectilePrefab, rigidbody2d.position + Vector2.up * 0.5f, Quaternion.identity);

    Projectile projectile = projectileObject.GetComponent<Projectile>();
    projectile.Launch(lookDirection, 300);

    // This should be "Launch" also you are not using ascii double quotes so copy and paste has a special “ instead of the asicii " one so visual studio gets upset.
    animator.SetTrigger(“Lauch”);
}

Regards,
Anthony

4 Likes

@Woolley_Kat Regarding World Interactions - Collectibles part 1 - character Health. The bottom exercise solution code to ‘expose speed’ by adding ‘public’ results in a compiler error? (newb here just starting out)

Fixed it ! further on down the chapter, don’t know how exactly, maybe i just forgot to put in that closing bracket, like the Console kept reminding me a couple of times? I’ll probably have to read and go over this chapter a couple of times more over before i truly grasp this beginner C# stuff.tx!

1 Like

Would like to ask if this game has mobile controls or pc only? thanks

Found what may be another issue?
In chapter 16 Build, Run, Distribute after having completed it and testing the finished build, my player character and enemy characters are moving way too fast. I’m guessing their movement speed is tied to the refresh rate or framerate, but it shouldn’t be as Time.deltaTime is incorporated in their scripts and it runs as expected in the Unity Editor.

This tutorial has been my first time using Unity, so I’m kind of at a roadblock. Any help would be appreciated!

edit: I have found that running on the default build’s ultra-medium settings causes the movements to be too fast, while low-very low cause them to be too slow. I can also replicate this issue in the editor by switching the Quality setting’s Vsync to Every Second V Blank. I have also checked to see if my GPU drivers were causing any interference but have determined that it is not. Any help still would be appreciated as this is is something I’d like to resolve in the event I encounter it again in different projects.

edit2: After no luck, I’m just going to assume it has something to do with unity tying my movement script to some part with my monitor’s refresh rate of 144hz. At this time I don’t have any other means to determine what may be the cause so if anyone has had or read of any similiar issues please let me know :stuck_out_tongue_winking_eye:

1 Like

Chapter 12 - 3 Particle System in code.
Code and tutorial parts missing?

The tutorial jumps directly to dragging the particle system in to a slot that hasn’t been created yet. Even if I create a public variable for for the smoke effect it still doesn’t work when I press play in the editor. Maybe I missed something, but after re-reading that section lots of times, I still cannot get it to work. Any help would be greatly appreciated.

11 Likes

This project has been created to be used within the Unity editor on Windows or Mac only.

Hey, I’m not having any luck with the Ruby Tutorial for beginners. I’m not sure why it’s just not working form me. But I have been trying to figure it out for a while and I’m only on the second part. The image I’ve posted has my script and the errors the console is showing me. Thanks to anyone who can offer a suggestion.

I have opened unity ver. 2018.3 and repeated the process. It worked correctly, unlike in unity ver. 2019.1.

2019 breaks a lot of the 2D tutorials. Stick with 2018.3 and you’ll save yourself a lot of aggravation.

2 Likes

Thank you for the tip.

1 Like
1 Like

Its not that, it seems he somehow managed to add duplicate of RubyController.c# to project and when he started clean it solved the problem.

Was camehere just to write that. But in someway it was good debugging exercise for me, had to write lots of test cases to find what is wrong and eventhough i know how to do it in theory first time i actually put the effort and done that :slight_smile: So i am glad of the bug for some reason.

i’m stuck at that point :frowning:

I saw the bug @anthonyirwin82 has shown on the first answer.
I changed
animator.SetFloat(“Look X”, lookDirection.x);
animator.SetFloat(“Look Y”, lookDirection.y);

but I keep on getting error:
NullReferenceException: Object reference not set to an instance of an object RubyController.Update () (at Assets/Scripts/RubyController.cs:51)

I commented out the three line:
//animator.SetFloat(“Look X”, lookDirection.x);
//animator.SetFloat(“Look Y”, lookDirection.y);
//animator.SetFloat(“Speed”, move.magnitude);

and the game can run
I’ve also debugged the 3 variable:

Debug.Log(lookDirection.x + “/” + lookDirection.y);
Debug.Log(move.magnitude);

and they works

so I think the problem is that

Animator animator;

is not working, but is written similar to EnemyController

someone got this problem to?

This is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RubyController : MonoBehaviour
{
public float speed = 3.0f;

public int maxHealth = 5;
public float timeInvincible = 2.0f;

public int health { get { return currentHealth; } }

private int currentHealth;
bool isInvincible;
float invincibleTimer;

Rigidbody2D rigidbody2d;
Animator animator;

// Start is called before the first frame update
void Start()
{
rigidbody2d = GetComponent();

currentHealth = maxHealth;
}

// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxis(“Horizontal”);
float vertical = Input.GetAxis(“Vertical”);

Vector2 move = new Vector2(horizontal, vertical);

Vector2 lookDirection = new Vector2(1, 0);

if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
{
lookDirection.Set(move.x, move.y);
lookDirection.Normalize();

}

//Debug.Log(lookDirection.x + “/” + lookDirection.y);
//Debug.Log(move.magnitude);
animator.SetFloat(“Look X”, lookDirection.x);
animator.SetFloat(“Look Y”, lookDirection.y);
animator.SetFloat(“Speed”, move.magnitude);

Vector2 position = rigidbody2d.position;

position = position + move * speed * Time.deltaTime;

rigidbody2d.MovePosition(position);

if (isInvincible)
{
invincibleTimer -= Time.deltaTime;
if (invincibleTimer < 0)
isInvincible = false;
}
}

public void ChangeHealth(int amount)
{
if (amount < 0)
{
if (isInvincible)
return;

isInvincible = true;
invincibleTimer = timeInvincible;
}

currentHealth = Mathf.Clamp(currentHealth + amount, 0, maxHealth);

Debug.Log(currentHealth + “/” + maxHealth);
}
}

thanks

I hope some one can help with this, it’s driving me nuts. I’m trying to make my star particle look identical to the example at the top of the Visual Styling - Particles tutorial page, but I can’t seem to adjust the particle system to achieve this. Can anyone tell me what the settings are for that? Mine doesn’t look anywhere near as smooth.

Here are my settings:

1 Like

Hey,
I don’t see anything wrong with the script at first sight, make sure you are using the right Animator controller in the editor and that you have the same parameters. You get a nullreference exception when those 3 lines are linked and not when you comment them, so I am guessing they can’t find the parameters you are wanting to access.

  1. I believe there is a small bug here in CH12PT3 - duplicate image. First one should be fixed if I’m not mistaken.

3 Likes

I actually have the same problem as you have. But I’m also not getting any smarter by looking into the references…
for the moment i commented those three lines and can play. But Animation is missing tho. ;(