Forum begins after the advertisement:


[Part 10] 2 Errors I’m confused about

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 10] 2 Errors I’m confused about

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #11906
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    (1) So, for the first issue, whenever I collect XP gems, only the first collect of the type is collected. This is really confusing because before part 11, it worked perfectly.

    (2) This error happens during the upgrade screen, but it appears that the onclick event is deleted before it can be used and I don’t know why. The code is the exact same(I think) and I can’t find console errors.

    Help would be appreciated!

    (if the answer is in part 11 I will eat my hat.)

    #11907
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Luke, I’m taking over the project from Xavier, so bear with me if I’m not very well-informed about some parts of the codebase.

    For (1), is the collision detection done using OnTriggerEnter2D()? If it is, you can do put something like Debug.Log(name + " pick up triggered") on the function to see if the function fires for the pickups that are not working. The line prints the name of the object as well, so you can tell which object is being triggered. If certain pickups are not triggering, pause the game during play and check if they have a) a collider and b) a Rigidbody2D. Those 2 are needed for collisions to register.

    For (2), will you be able to clip a video of this happening with something like ScreenToGif and post it on Imgur? Then you can embed it here.

    #11908
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    Here is ScreenToGif’s download link: https://www.screentogif.com/downloads

    #11910
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    I’ve tested out the Debug.Log solution and I think the reason is because it is destroyed before it hits the player. Still not solved.(I could be wrong on this.)

    (btw u can use print() instead of debug.log)

    #11911
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    Is there any script that is calling Destroy() on your GameObject? That is the only thing I can think of that is destroying your object before it hits the player.

    #11912
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    The error might be in onTriggerEnter2D for this code:

    void OnTriggerEnter2D(Collider2D col)
        {
            if (col.gameObject.TryGetComponent(out ICollectible collectible))
            {
                Rigidbody2D rb = col.gameObject.GetComponent<Rigidbody2D>();
                //rb.velocity = Vector2.zero;
                //rb.angularVelocity = 0;
                collectible.MoveToPlayer();
                collectible.Collect();
            }
        }

    Also I’ve recorded the other error, but I don’t know how to embed.

    #11913
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    The error might be in onTriggerEnter2D for this code:

    void OnTriggerEnter2D(Collider2D col)
        {
            if (col.gameObject.TryGetComponent(out ICollectible collectible))
            {
                Rigidbody2D rb = col.gameObject.GetComponent<Rigidbody2D>();
                //rb.velocity = Vector2.zero;
                //rb.angularVelocity = 0;
                collectible.MoveToPlayer();
                collectible.Collect();
            }
        }

    Also I’ve recorded the other error here.
    The Error

    #11914
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    I solved the issue where you could dodge pickups using the movetoplayer function above, complicated.
    if that causes an error welp that’s it.

    #11915
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    I solved the issue where you could dodge pickups using the movetoplayer function above, complicated.
    if that causes an error welp that’s it.

    #11916
    Luke
    Participant
    Helpful?
    Up
    0
    ::

    Nvm, the second error was because I decided to put removeUpgradeoptions after applyupgradeoptions. Fixed!

    #11920
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Luke, glad you managed to fix the issues!

    #12065
    Pavel Fára
    Participant
    Helpful?
    Up
    0
    ::

    Hi i have solution for your 1 Error if you need it. Sadly it wont let me post imagur or other images or links into reply. Can i contact you somehow outside of this forum?

    #12130
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Pavel, of course. I’ve dropped you an email. You can contact me through there.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: