Forum begins after the advertisement:


[part 10] dive causes unity to freeze completely

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [part 10] dive causes unity to freeze completely

Viewing 6 posts - 41 through 46 (of 46 total)
  • Author
    Posts
  • #16094
    Niyam Shah
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    yep so the bot is deinfately stuck in the jump animation until hit

    also yes my jump animation and dive animation are both non-looping

    View post on imgur.com
    #16097
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    Let’s try setting your animation transition arrow from “Jump” to “Idle” to have the conditions.

    “Jump = false” “DiveAttack = false”

    #16098
    Niyam Shah
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    YES!!!! THE ERROR IS FIXED!!!!!!!!1 thanks so much for ur help

    one last thing….. do u know how to fix my camera jitter? ive tried interpolating/extrapolating my character and the camera, reducing character walkspeed

    extrapolating the character makes movement feel really good but interpolating makes my character feel very very sluggish and slow

    but nothing seems to make the camera jitter go away

    this is one of those problems that just appeared when transferring my game to my new laptop (it worked perfectly beforer the transfer)

    #16099
    Niyam Shah
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    small update…… so the error isnt completely fixed

    the boss getting stuck on the wall error is fixed

    but sometimes if im really close to the boss, itll repeat the jumping animation endlessly..

    View post on imgur.com

    at least we r halfway through with these bugs!!

    #16108
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    By the way, the animator will not show the current animations being played until you click on the Scene’s Boss again after playing the game. So whenever you press play, remember to select the boss in the hierarchy again.


    Again this is likely due to you hitting the boss on wakeup, causing it to start ResetAllAttacks(), turning off diveAttack.

    Looking at your jump script again, it’s probable that your boss is stuck in jump cause it cannot activate DiveAttack() due to the bool being off in OnStateUpdate().

    
    
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            if (WoodenBot.Instance.diveAttack)
            {
                DiveAttack();
            }
        }
    

    Let’s see if this works and could you send your new dive script as well to see the updated ver.

    [There’s also an issue with this since we are essentially removing the function of diveAttack bool, but it should be fine for now.]

    #16110
    Niyam Shah
    Level 8
    Participant
    Helpful?
    Up
    0
    ::

    i dont want to jinx it but it seems to be fixed….. im not experiencing the issue anymore…

    heres the jump script anyway

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

    public class WoodenBotJump : StateMachineBehaviour { Rigidbody2D rb;

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        rb = animator.GetComponentInParent<Rigidbody2D>();
    }
    
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    
            DiveAttack();
    
    
    }
    
    void DiveAttack()
    {
    
    
            WoodenBot.Instance.Flip();
    
            Vector2 _newPos = Vector2.MoveTowards(rb.position, WoodenBot.Instance.moveToPosition, WoodenBot.Instance.speed * 3 * Time.fixedDeltaTime);
    
    
            rb.MovePosition(_newPos);
    
            float _distance = Vector2.Distance(rb.position, _newPos);
    
            if (_distance < 0.1f)
            {
                WoodenBot.Instance.Dive();
            }
    
            if (WoodenBot.Instance.TouchedWall())
            {
                WoodenBot.Instance.moveToPosition.x = rb.velocity.x;
    
                _newPos = Vector2.MoveTowards(rb.position, WoodenBot.Instance.moveToPosition, WoodenBot.Instance.speed * Random.Range(2, 4) * Time.fixedDeltaTime);
    
            }
    
    
    }
    
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    
    }

    }`

    heres the new dive script:

    <code>using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class WoodenBotDive : StateMachineBehaviour
    {
        Rigidbody2D rb;
    
        bool callOnce;
    
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            rb = animator.GetComponentInParent<Rigidbody2D>();
        }
    
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            WoodenBot.Instance.divingCollider.SetActive(true);
    
            if (WoodenBot.Instance.Grounded())
            {
                WoodenBot.Instance.divingCollider.SetActive(false);
    
                if (!callOnce && DivingPillar.count < 10)
                {
                    Debug.Log("callOnce is true");
                    WoodenBot.Instance.DivingPillars();
                    animator.SetBool("Dive", false);
                    WoodenBot.Instance.ResetAllAttacks();
                    callOnce = true;
                }
    
            }
        }
    
        override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            callOnce = false;
            Debug.Log("CallOnce is false");
        }
    
    }</code>

    thanks so much for your help

    lets hope i dont get any errors with part 10.5………

Viewing 6 posts - 41 through 46 (of 46 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: