Search Unity

Unity Ruby’s Adventure: 2d Beginner Official Thread

Discussion in 'Community Learning & Teaching' started by Woolley_Kat, Apr 15, 2019.

  1. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,463
    Are you absolutely sure about that? I'm asking because, when you create a 2D project with the 2D template, the necessary 2D packages are not installed by default. Maybe the camera is not set on orthographic by default either... It is in 2019.2.11f1, but you never know.

    What version of Unity are you using?
     
  2. SandVampire

    SandVampire

    Joined:
    Oct 5, 2018
    Posts:
    2
    Hi, in the UI tutorial, I've followed the instructions. However, when I created the health bar mask (part 10) and tried to resize the mask object, the health bar got resized instead of getting cropped (see the attached video). Has anyone else encountered this problem?
     
  3. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    180
    upload_2019-11-19_16-47-34.png
     
  4. SandVampire

    SandVampire

    Joined:
    Oct 5, 2018
    Posts:
    2
  5. AnAlienDream

    AnAlienDream

    Joined:
    Oct 19, 2019
    Posts:
    8
    I have problem with the particle system; I've managed to set the hit effect (an effect that plays when Ruby takes damage) to trigger correctly with this:
    Instantiate(hitEffect, transform.position, Quaternion.identity);
    I've also disabled Looping, but if I have Stop action set to "Destroy" and I try to take damage, it gives me an error saying: "The object of type ParticleSystem has been destroyed but you are still trying to access it".

    If I set the Stop action to "None" the effect works, but then it keeps creating clones that don't disappear, which I (probably) don't want. Any help?
     
  6. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    180
    When dragging and dropping your HitEffect Particle System into the relevant slot in the Inspector, make sure you drag it from the Prefabs folder in the Project window and not from the Hierarchy.
     
  7. AnAlienDream

    AnAlienDream

    Joined:
    Oct 19, 2019
    Posts:
    8
    Thank you, that worked!
     
  8. aazizorg

    aazizorg

    Joined:
    Sep 26, 2017
    Posts:
    1
    Okay I have spent a good amount of time on this, the only part of the tutorial that I can't figure out myself so far. I put my smoke effect prefab on the Robot prefab and moved it to behind the robot's head. In the prefab scene window it shows this correctly, but in game it still only shows up at the 0,0 point relative to the robot (or at least it appears in the lower half, not sure on the exact coords).

    Any ideas?

    Edit: I was able to fix it, I think it was either setting the pivot point from Center to Bottom, or fixing the Z axis.
     
    Last edited: Nov 26, 2019
  9. AnAlienDream

    AnAlienDream

    Joined:
    Oct 19, 2019
    Posts:
    8
    I've finished the tutorial but I'm still having problems with Ruby colliding with other objects, especially now since I'm trying to redecorate my world. For example with the house; I want Ruby to be able to walk behind the house but collide with the lower part of the house, but since Ruby's collider is on her feet (like it was shown in the tutorial), her upper body still goes through the house. Similar problems also appear on other objects. What should I do with this?
    Collide.png Collide2.png Collide3.png

    Update: I've managed to get the effect somehow by creating a sorting layer and adding Ruby and the House in the same sorting layer. Now Ruby is in front of the house at the lower part of the house and behind it at the upper part of the house, but she appears on top of it in the middle. I tried to mess around with the order of layers and the "Transparency in sort mode" setting, but I don't know how to fix this...
    collidec.png

    Update's update: The problem was that I hadn't set the house's sprite sort point to pivot, now it works well :D
     
    Last edited: Dec 11, 2019
  10. LemonPrime

    LemonPrime

    Joined:
    Nov 17, 2019
    Posts:
    4
    Hi,I meet a problem in "Sprite animation".Ruby's animation works all good.But the robot didn't work as expected.The robot moves without animation.
    The console shows that"Parameter 'Move X' does not exist."
    But I did set the Parameters to Move X and Move Y 6LKS[JH_N]GGL$2Y{C~R@VN.png 3CLZRGUB4Z`}RWSC_M@{}OD.png
    I check many times and I still couldn't solve it.:(
     

    Attached Files:

  11. AnAlienDream

    AnAlienDream

    Joined:
    Oct 19, 2019
    Posts:
    8
    Have you also checked that in the EnemyController-script you've spelled "Move X" and "Move Y" correctly? (in case you've spelled "move x" and "move y" for example, that was my problem at some point)
     
  12. DieGeileSchnitte

    DieGeileSchnitte

    Joined:
    Oct 19, 2019
    Posts:
    2
    Hi there, I'm currently having problems with the health collectible, the collectible doesn't react, when Ruby is on it.
    Can someone please help me?
    Here's a quick video of the problem:
     
  13. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    180
    Ruby can’t collect health collectibles at this stage in your project because she has not suffered any damage and is, therefore, at maximum health.

    In the next tutorial in the project, you will add Damage Zones and Enemies. These GameObjects will hurt Ruby and cause her health to decrease, at which point you will be able to collect the health collectibles until she returns to maximum health.
     
    DieGeileSchnitte likes this.
  14. DieGeileSchnitte

    DieGeileSchnitte

    Joined:
    Oct 19, 2019
    Posts:
    2
    Ohhh:rolleyes::oops:, thank you so much!
     
  15. rekcilF

    rekcilF

    Joined:
    Nov 8, 2019
    Posts:
    1
    I need some help with an error I can't seem to fix:
    NullReferenceException: Object reference not set to an instance of an object
    UIHealthBar.SetValue (System.Single value) (at Assets/Scripts/UIHealthBar.cs:25)
    RubyController.ChangeHealth (System.Int32 amount) (at Assets/Scripts/RubyController.cs:82)
    DamageZone.OnTriggerStay2D (UnityEngine.Collider2D other) (at Assets/Scripts/DamageZone.cs:17)

    with this for the rubycontroller
    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 GameObject projectilePrefab;
    public int health { get { return currentHealth; } }
    public int currentHealth;
    bool isInvincible;
    float invincibleTimer;
    Rigidbody2D rigidbody2d;
    Animator animator;
    Vector2 lookDirection = new Vector2(1, 0);
    // Start is called before the first frame update
    void Start()
    {
    rigidbody2d = GetComponent<Rigidbody2D>();
    animator = GetComponent<Animator>();
    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);
    if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
    {
    lookDirection.Set(move.x, move.y);
    lookDirection.Normalize();
    }
    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;
    }
    if (Input.GetKeyDown(KeyCode.C))
    {
    Launch();
    }
    }
    public void ChangeHealth(int amount)
    {
    if (amount < 0)
    {
    if (isInvincible)
    return;
    isInvincible = true;
    invincibleTimer = timeInvincible;
    }
    currentHealth = Mathf.Clamp(currentHealth + amount, 0, maxHealth);
    UIHealthBar.instance.SetValue(currentHealth / (float)maxHealth);
    }
    void Launch()
    {
    GameObject projectileObject = Instantiate(projectilePrefab, rigidbody2d.position + Vector2.up * 0.5f, Quaternion.identity);
    Projectile projectile = projectileObject.GetComponent<Projectile>();
    projectile.Launch(lookDirection, 300);
    animator.SetTrigger("Launch");
    }
    }
    and this for the damage zone handler

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class DamageZone : MonoBehaviour
    {


    // OnTriggerEnter2D means once ruby enters once and stays it only damages once but OnTriggerStay2D means ruby gets damaged continuosly
    void OnTriggerStay2D(Collider2D other)
    {
    RubyController controller = other.GetComponent<RubyController>();
    if (controller != null)
    {
    controller.ChangeHealth(-1);
    }

    }
    }
     
  16. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    I fix it moving some code from Update to FixedUpdate function and moving some declarations from Update to the top of tje class
    I Upload my script, changes are all comented maybe it help others with same issue.
    Sorry my english, is awful XD.
     

    Attached Files:

  17. Longbottom76

    Longbottom76

    Joined:
    Aug 15, 2016
    Posts:
    1
    Does anyone know why my smokeEffect child of my Robot prefab spawns in the correct location while I have my game stopped (near the robot's head), but once I start the game, the smoke spawns right at the foot of the robot?

    I've followed instructions and dragged my smokeEffect prefab onto the Robot prefab (not in the hierarchy, but while I have Robot prefab open) to make it a child.

    I've reviewed my Robot prefab to make sure it is set to position 0,0,0. Moving my smokeEffect up a little bit so it is closer to the robot's head, that position is 0, 0.2, 0 while viewing it in the robot prefab. Also checked the base smokeEffect prefab and that is set to position 0,0,0.

    Like I said, it renders correctly while I have the game stopped and in scene view. Also, looks good when I view the robot prefab with child.

    I have tested the X value (horizontal position) to see if the whole position is being reset to 0,0,0 somehow, but when I offset the X value of the smokeEffect child something other than 0 that works as it should, the smoke spawns at the X value that I set. The vertical position of the smoke always spawns at the robot's feet, even while the X offset is other than 0.

    Thanks for any advice.
     
  18. dlookenb

    dlookenb

    Joined:
    Jan 25, 2020
    Posts:
    1
    Hi All,

    Newbie here. Going through the particles tutorial, after adding the smoke to the robot prefab and running the game, the smoke does not appear on the robot. I placed another prefab of the smoke particles just on one of the orange game tiles, and I can see the smoke but only very tiny puffs of smoke.

    Anyone else having this issue where the smoke is not (or is very barely) visible? Something wrong with my visual settings or layers?

    My smoke transform is set at Z=0 as some other users have suggested may fix it, but I'm still having this issue.

    Thanks for any help!
     
  19. notorirandom

    notorirandom

    Joined:
    Jan 20, 2019
    Posts:
    5
    in lesson 13: Visual Styling - User Interface - Head-Up Display, I can run normally. But unity gives me error: upload_2020-2-5_20-10-19.png
    I actually add
    Code (CSharp):
    1. void Awake()
    in the code, but the error still there. It has no affect to my game, but I want to fix this problem.
    upload_2020-2-5_20-12-24.png
    Appreciate to your help
     
  20. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    180
    Did you drag the Mask from the Hierarchy into the field labelled “Mask” in the UI Health Bar (Script) component attached to the Health Bar GameObject in the Inspector?
     
  21. notorirandom

    notorirandom

    Joined:
    Jan 20, 2019
    Posts:
    5
    Thank you for your help.

    Yes, I have dragged the mask to the Script. As I said before, the game runs without any problem, if i didn't drag it, the game can't show the health bar UI.

    The problem is that, everything is set as the tutorial and the game can run, there is still has the error: "NullReferenceException: Object reference not set to an instance of an object", I can't fix that.

    If you need any other code or screenshot to check the problem, please let me know.
     
  22. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    180
    The game will show the Health Bar UI even without dragging the Mask into the Script component. However, the Health Bar will not update when Ruby receives damage.

    Does your Health Bar respond to Ruby receiving damage?

    When you clear the Console, does the error reappear when you enter Play Mode?
     
  23. notorirandom

    notorirandom

    Joined:
    Jan 20, 2019
    Posts:
    5
    I have checked it again, it seems that I put the mask to the wrong place. Thank you for your reminding, I have fix the problem.

    Thank you very much
     
  24. brazinbraku

    brazinbraku

    Joined:
    Feb 5, 2020
    Posts:
    1
    I experienced a similar issue. I first tested the build with ultra settings on a monitor with 120hz refresh and the bot animations were laggy/ruby was running slowly and chopping every so often. I have a 60hz monitor as a secondary - tried it there with same settings and it ran smoothly again.

    The solution is to use the FixedUpdate() method in place of the Update() method on the physics objects (Ruby, Bot, projectile). Retested on both monitors and worked seamlessly.

    reference doc: https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html
     
  25. gtrcrazynik

    gtrcrazynik

    Joined:
    Dec 21, 2019
    Posts:
    7
    noticed it too
     
  26. Axel1971

    Axel1971

    Joined:
    Feb 17, 2020
    Posts:
    2
    Hi,

    I followed the tutorial until Sprite Animation. There is mentioned in the beginning to use the robot prefab. Which one shall that be? Before this section we defined ruby and the enemy but no "robot". In the asset area isn't anything called robot (only in the audio section) ....

    Is the robot sprite graphics missing?

    kind regards
     
  27. Axel1971

    Axel1971

    Joined:
    Feb 17, 2020
    Posts:
    2
    or is it a mismatch in the tutorial, because the tutorial would like to tell us to use the "enemy" ?
     
  28. HP_player

    HP_player

    Joined:
    Feb 19, 2020
    Posts:
    1
    I have the same problem now but since I am still struggling with the robot animation, in my case it’s the robot that moves in the right direction but with no animation.I also copied the code from the tutorial and I think I precisely followed the steps in the tutorial. Have you solved this problem? If so, maybe you can give some advice for help?
     
  29. JP0490

    JP0490

    Joined:
    Nov 11, 2019
    Posts:
    2
    Hello to see if someone can help me with some mistakes that I have, when I launch the projectile I get a warning that says "Parameter 'Launch' does not exist.
    UnityEngine.Animator: SetTrigger (String)
    RubyController: Launch () (at Assets / Scripts / RubyController.cs: 98)
    RubyController: Update () (at Assets / Scripts / RubyController.cs: 67) "

    Also another error makes the robot when "dies" stays in the same place making the animation and does not disappear,
    and I can move it to him while he walks and he also to me.

    Finally the life bar does not go down when they hurt me, only Ruby's face disappears but the blue bar is still intact, what am I doing wrong? thanks for your help !
     
  30. JP0490

    JP0490

    Joined:
    Nov 11, 2019
    Posts:
    2
  31. K_Daeke

    K_Daeke

    Joined:
    Jul 23, 2019
    Posts:
    2
    I encountered a problem in the sprite animation section!

    After implementing Ruby's animation code in part 9 section 11, Ruby isn't moving properly. She can't move up or down and runs to the right whenever a horizontal control key is pressed. How do I fix it?
     
  32. K_Daeke

    K_Daeke

    Joined:
    Jul 23, 2019
    Posts:
    2
    I added the following lines of code to my ChangeHealth function and set my stop action to Callback, not destroy. transform.position makes sure the effect spawns on top of your player and setting the stop action to callback will allow the effect to be replayed. Setting it to destroy will, well, destroy the particle system!

    if (amount < 0)
    {
    // Instantiate(burstEffect, transform.position, Quaternion.identity);
    // burstEffect.Play();

    animator.SetTrigger("Hit");

    if (isInvincible)
    return;

    isInvincible = true;
    invincibleTimer = timeInvincible;

    Instantiate(burstEffect, transform.position, Quaternion.identity);
    burstEffect.Play();



     
  33. guil182

    guil182

    Joined:
    Mar 16, 2020
    Posts:
    1
    Hi,

    I just installed unity 2019.3.5f1 and downloaded ruby's adventure project.

    But I can't open it !
    I have a message "you need to install editor version 2019.2 to open it"

    How to solve it please ?

    Regards
     
    HagureShinma likes this.
  34. D-Cahill

    D-Cahill

    Joined:
    Mar 23, 2020
    Posts:
    1
    Download version 2019.2 from here: https://unity3d.com/get-unity/download/archive
     
  35. JoniD89

    JoniD89

    Joined:
    Mar 22, 2020
    Posts:
    1
  36. bosstradamus

    bosstradamus

    Joined:
    Mar 22, 2020
    Posts:
    1
    I'm having a similar issue.

    The box collider seems to be to the right of each box.
     
  37. EinhanderX2

    EinhanderX2

    Joined:
    Apr 2, 2020
    Posts:
    1
    This solved it for me, my Z was -200. Not sure how that happened.
     
  38. dokujaryu

    dokujaryu

    Joined:
    Today
    Posts:
    1
    I'm new to Unity, but I was wondering, why do we have to use 2019.2 instead of 2019.3? Also, I have 2018.4 installed, and all the documentation seems to indicate that this will work, but it seems the project cannot open with anything but 2019.2. Is there some way to migrate a project to 2019.3? Or is it just too specific to try this?
     
unityunity