That’s your problem. You are not using ShowHideCraftingUI
to close the window, so nothing is going to tell the state to switch back. You could just replace that to be the CraftingSystem.CloseCrafting()
AND… Yes, I got it to work. I changed the event on the quit button to ‘CraftingUI.CraftingSystem.CloseCrafting()’, and miraculously, it does exactly what I want it to do. Disable the movement and everything else until the quit button is clicked
Sorry again for the mess man, and thank you again so so much for standing by my side through this. It’s extremely appreciated
before we finish this off though, this is a quick question on the fly, but do you know by chance how to lock the cinemachine freelook camera’s rotation when the Crafting UI is open? again, until the quit button is pressed (and I’m assuming the function that automatically closes the UI when the player is under sudden attack is still working)
Not miraculous, code can’t run if you’re not telling it to. No-one says; ‘This guy stopped eating and miraculously he died’.
Maybe switch to a different camera. Like we do for targeting. I’d find an animation that looks like I’m using the table and use the state driven camera to switch to a fixed camera when I’m crafting, but you could also just have a fixed camera somewhere and switch to it. When I say ‘fixed camera’ it will probably still be a cinemachine camera. Maybe the Target Group camera that will frame both the player and the crafting table.
true (I’ll go read through all of this again for now, just to ensure I understand even just a bit of what we went through… because this was kinda like a maze tbh)
I’ll definitely check on this another day. For now just wait for Brian to see what he has to say on the Construction System’s saving system, and then check on the bank UI challenge, along with the performance issues I currently have (I’ll explain that in detail when we get to it )
Ehh I just want something that has the movement coordinates frozen, just to avoid confusing the player with the background (the simpler, and fairly challenging the game gets, the better. I don’t want to over-engineer it, as I learned from the mistakes of other developers on the internet)
Simple breakdown;
- We added an event to the crafting table, and a method that invokes the event when the table is closed,
- We subscribed (and unsubscribed) to the event in the crafting state and listened for it to fire, at which point we returned to the freelook state,
- We added code to the crafting system that will let the crafting table know when it is closed, so that it can invoke the event.
You could also just add a camera to the crafting table prefab that is fixed and framing the table. When the table opens, you switch to it (table will need a reference to it) and when the table closes you switch back. You can switch back and forth by just setting the priority higher or lower than the active camera. So, you don’t need to know which camera was active, you just set the table’s camera to a higher priority and it will become the active camera. When you are done, you set it low again and the previous highest camera will be active again. If the active camera is always at priority 15, you set the table camera to 20 to make it active, and then 10 (or 0 or anything lower than 15) to activate the original active camera
First of all, this is incredibly helpful. Again, thank you bixarrio for taking the effort to not only help me through this, but to also explain it in simple terms (mind you though, processing it in my mind might take some time, but I’ll try )
How do we change the camera priority through code though? I know how to do it in inspector, I’ll need to google up how to do it through code
tableCamera.Priority = 20;
Fair enough
Meanwhile I’ll go have a look at how we can get resource gathering to blend in with this system (EDIT: 7 days later, still yet to do that…)
On a serious note though, the fact that Brian makes this all accessible with one button in-game, through his ‘HandleAttackButtonPressed()’ function is the most fascinating part to me out of all of this
hey guys, something I noticed is that the combat targeting camera no longer works after I save and return to a game. It’s a bit of a rare bug, but sometimes it does happen… Is that the case for you all as well, or just me?
Don’t want to jump into multiple topics at once, just figured I’d bring that up now
That one I can’t explain, as the cameras have exactly nothing to do with the saving system…
Which took me by surprise as well… It does happen from time to time, and I’m not sure why (this project is a bunch of surprises, all at one…)
And the mover saving system became a mess recently, as my player now, when he returns to the game, is saved at the starting point more often than at where he was last at, before the game was saved… I didn’t do anything to it
This is a known issue and we’ll be tackling that issue at a later date. Remember how we had to fight with NavmeshAgent in Mover? Now we also have to fight with CharacterController (at the same time, when it comes to the enemies).
lol we fighting the world now - all good though, as long as it’s a known issue
As for the combat mode failing to toggle, that’s something I’ll probably investigate down the line as well. It’s an existing bug though, and it happens at about 30% of the time when you save and restore files
That’s literally not what you said. You said the camera wasn’t working…
Next time that happens, look for an error message…
that was miscommunication from my behalf, apologies
Anyway, when it happens, I’ll keep you updated
Speaking of errors, there are 2 that keep happening during runtime and won’t be quiet:
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent:set_destination (UnityEngine.Vector3)
RPG.Movement.Mover:MoveTo (UnityEngine.Vector3,single) (at Assets/Project Backup/Scripts/Movement/Mover.cs:79)
RPG.Movement.Mover:StartMoverAction (UnityEngine.Vector3,single) (at Assets/Project Backup/Scripts/Movement/Mover.cs:43)
RPG.Control.AIController:PatrolBehaviour () (at Assets/Project Backup/Scripts/Control/AIController.cs:273)
RPG.Control.AIController:Update () (at Assets/Project Backup/Scripts/Control/AIController.cs:139)
"Resume" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
RPG.Movement.Mover:MoveTo (UnityEngine.Vector3,single) (at Assets/Project Backup/Scripts/Movement/Mover.cs:84)
RPG.Movement.Mover:StartMoverAction (UnityEngine.Vector3,single) (at Assets/Project Backup/Scripts/Movement/Mover.cs:43)
RPG.Control.AIController:PatrolBehaviour () (at Assets/Project Backup/Scripts/Control/AIController.cs:273)
RPG.Control.AIController:Update () (at Assets/Project Backup/Scripts/Control/AIController.cs:139)
If you see ‘AIController.cs’ in the stack, that’s because I am currently working on one enemy with the tutorial before going wild with the rest
One of your characters isn’t quite on the NavMesh, at a guess (which is typical). If it’s a yellow warning that pops up from time to time, ignore it. If it’s a red warning, then your character isn’t on a NavMesh, or has an agent type that doesn’t match the NavMesh Surface (each different agent type gets it’s own Surface).
it’s red, and consistent lel… I’ll place them on the NavMesh I suppose. Will the upcoming Force Receiver script for the enemies solve the problem?
that’s in 2021 LTS as well? How do you get them to match? apparently dragging a character up and down didn’t help…
umm… Brian, quick question(S… this one ended to be much harder than I anticipated…) before this turns into a train-wreck. How bad would it be if I stick to the Unity 2021.3.21f1 LTS Navmesh instead of upgrading it? I’m just terrified of the plethora of errors that will happen if I make the switch, idk what to expect
I was reading the “Enemy Chasing State” page, when this popped into my head
(more importantly, how do you upgrade your NavMeshAgent? can I upgrade that in 2021 LTS? upgrading to 2022 will cause me countless unwanted problems )
Edit (more like Question 2): I skipped the ‘Improved Animations’ section, and my enemies are not chasing me, even with the state machine intact. That’s expected, right? Or is it something other than the animations that’s causing the issue?
Edit 2 (Question 3): in the “BlendTreeMadness” tutorial, does the Blend Tree we’re creating replace our ‘ThirdPersonHumanoid’ Animator, is an add-on, or…? I placed the ‘ThirdPersonHumanoid’ animator on my player, and now my enemies… hence why I’m asking (welcome to another day of “Bahaa accidentally got himself into multiple issues at once ”)
Edit 3 (Question 4): I know we probably did this a lot in the past, but my brain is fried as we speak (literally), so can we please discuss one more time:
a. How to get the animations to be in-place? Is there a “Root Motion” tick hidden somewhere I don’t know about? (I’m using Kevin Iglesias’ Animations as we speak)
b. How do you get the multiple parameters for the blend tree? I did the 2D trick we did in the third person course, but some of yours have 3 parameters, and I have no idea how you did that, so it’s quite a mess…
I DO HAVE TO HIGHLIGHT THOUGH, THAT WITH THE CURRENT STATE, MY TARGETINGBLENDTREE ANIMATIONS ONLY RUN BASED ON THE STATE THE PLAYER ENTERS THE TARGETING STATE WITH:
- So if he enters targeting state while running, it loops there forever until we exit the animation
- If he enters the state while standing still, he can move around in the targeting state, but no animations will play
(SIDE NOTE): I can’t get the player to not get into targeting state in the game engine, but if I load an old save in the game build, the player SOMETIMES won’t even detect a target to get into targeting state with
This is mine:
And this is yours (the one I’m trying to replicate):
Not necessarily with the names (mainly because if things go bad, for now, I want to know which animation was responsible for the trainwreck), just the parameters (because again, I have no clue how you got 3 parameters, or am I missing something…)
- Just to reassure, because there’s no Gitlink to the “Blend Tree Madness”, this “Spawn()” script is correct, right? (Ignore all the comments, they were failed attempts at creating dual-handed weapons… that’s for another day):
public Weapon Spawn(Transform rightHand, Transform leftHand, Animator animator) {
// This function starts off by destroying any old weapons the player
// is holding, by checking both player hands, and then it Instantiates
// the new weapon the player picked up into his hand, based on which
// hand the weapon belongs to (and then it gives it a name)
DestroyOldWeapon(rightHand, leftHand);
// DestroyOtherWeapon(rightHand, leftHand); // OUT OF COURSE CONTENT: Function that destroys other-handed weapons
Weapon weapon = null;
// Weapon weapon2 = null; // OUT OF COURSE CONTENT: Second weapon is initially at null
if (equippedPrefab != null) {
Transform handTransform = GetTransform(rightHand, leftHand);
weapon = Instantiate(equippedPrefab, handTransform); // If we have a weapon to arm up the Player/Enemy, Instantiate it into the Weapon holder's hand
weapon.gameObject.name = weaponName;
}
// --------------------------------- OUT OF COURSE CONTENT ----------------------------------------------
/* if (equippedPrefab != null) {
Transform handTransform = GetMainHand(rightHand, leftHand);
if (mainHand == WeaponHands.left) { weapon = Instantiate(equippedPrefab, handTransform); }
if (mainHand == WeaponHands.right) { weapon = Instantiate(equippedPrefab, handTransform); }
if (mainHand == WeaponHands.both) {
weapon = Instantiate(equippedPrefab, rightHand);
if (equippedPrefab2 != null && isDualWield) {
weapon2 = Instantiate(equippedPrefab2, leftHand);
weapon2.gameObject.name = weaponName2;
}
} */
// ------------------------------------------------------------------------------------------------------
// GLITCH FIXING BELOW: -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (!animator.gameObject.CompareTag("Player")) {
var overrideController = animator.runtimeAnimatorController as AnimatorOverrideController;
// the line above casts our current Animator runtime controller to override our current Animator Override Controller
// (if our animator is confused of what to do)
if (animatorOverride != null) {
animator.runtimeAnimatorController = animatorOverride; // if we have an Animator Override, we want to set our Animator Runtime controller to be equal to that
}
else if (overrideController != null) {
// If we have an override Controller, we want to set
// our Animators' Runtime Controller to be what our
// Override Controller has
animator.runtimeAnimatorController = overrideController.runtimeAnimatorController;
// if we have an override controller, find the parent animator and put this into the runtimeAnimator slot
// of that parent
// END OF GLITCH FIXING ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
}
else {
animator.SetFloat("WeaponType", animatorWeaponType);
}
return weapon;
}