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
- This topic has 45 replies, 3 voices, and was last updated 10 months, 2 weeks ago by
Niyam Shah.
-
AuthorPosts
-
October 16, 2024 at 9:33 pm #16094::
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
October 17, 2024 at 3:20 am #16097::Let’s try setting your animation transition arrow from “Jump” to “Idle” to have the conditions.
“Jump = false” “DiveAttack = false”
October 17, 2024 at 5:09 am #16098::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)
October 17, 2024 at 5:15 am #16099::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!!
October 18, 2024 at 4:11 pm #16108::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 offdiveAttack
.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 inOnStateUpdate()
.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.]October 18, 2024 at 11:37 pm #16110::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………
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: