One.
When we get to enemies, then weāll create another more streamlined version (and non humanoid enemies will each need their own as well, like say, a spider). Weāll burn that bridge when we get to it.
Yup, done with the new Animator, and it works well (obviously had to swap it in the Play hierarchy as well, just documenting it here so I donāt forget later)
Iāll continue the rest of the lectures either tonight or tomorrow, but so far so good
Quick question on the fly, before I start throwing more doubts hereā¦ how do you stop the camera from going nuts when you exit targeting state? When we go from targeting to freelook, it rotates like crazy for a second before being stable again. I tried fixing that in the main course as well, but failed. Thatā¦ and the side dodging system both failed
and before we get into attacking states, itās completely normal that my player tends to run from fights (i.e: step back) if heās in a fight in targeting state?
Nathan addresses this in one of the later lectures in the course, I donāt have the solution off hand here at work at the moment (nor the time to re-watch those sections to find it)
Once you switch to the targeting state, youāll constantly face the enemy and your controllerās movement will be relative to the player, not the camera.
I thought it was regarding the collider being set to just ignore the player collider, but apparently notā¦ Iāll try search it up
True, but if I get close to the enemy, like too close, my player tends to want to try step back a few steps for some reason (not sure why, but I think the attacking issue should be gone by the time the new system is in). It only happens when the real-life player tries clicking the attack button with his mouse
Which also results in this error:
"Stop" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
RPG.Movement.Mover:Cancel () (at Assets/Scripts/Movement/Mover.cs:66)
RPG.Combat.Fighter:Update () (at Assets/Scripts/Combat/Fighter.cs:65)
Just another question from the āAttackingā lecturesā¦ youāre using the solution you once taught me for my 2H Sword to apply a hit value, right? Where we find a specific time in an animation to trigger a hit function if Iām not mistaken
Yes, but since there is no ātargetā (well, there is if youāre in targeting mode, but not in FreeLook), rather than just hitting a set target, weāll do a OverlapSphere test to get all characters within a certain range and damage them.
On the Cinemachine collider, you do set it to ignore the player. Canāt tell you how from work, but I thought I put it in the tutorial.
I left that alone for most of the tutorial, but what you want to do is
- Remove the PlayerController
- Add an if(CompareTag(āPlayerā)) return; in Fighterās Update and Attack() methods.
Fair enough, Iāll give it a go in the morning. I threw in a RAW āPlayerAttackingState.csā into the test project and it went wild with the errorsā¦ Figured Iād give it a break tonight
Will check the rest as well soon
Regarding the Cinemachine collider ignoring the player, I manually did that a while ago, but the camera still goes wild. I even tried changing the layers to make it stop flying over collide objects, still failed
Try downloading the course project against the repo lecture (ideally, what you would do is clone the repo and move the commit to the lecture, then it looks exactly like it does at that page, but you can also just download the zip directly). Then compare the settings on the camera(s) in the course project to the settings on the camera(s) in yours. Hint: I actually tried to stay pretty close to what Nathan did.
The Attacking State and the Attack are things that (by necessity) will start seeing significant changes from the Third Person Course, and my lectures get a bit more verbose starting there.
By course project, youāre talking about the third person course? Iām cross checking my copy of the third person against the test copy Iām trying to implement this system on, to see why my camera acts wild (ill recheck it tomorrow)
Or is there a copy of the third person I can also downloadā¦?!
Edit: you said repoā¦ Iāll check that in the morning
At the bottom of each page in this tutorial is
This Pageās GitLab Commit
If you click on this link, you can see the project exactly as it was when I wrote the page (just like our lectures in our courses)
From there, click on Browse Files, then Code, an you can download the Zip of the course
umm, Brianā¦ at the end of lecture 19, itās normal that āPlayerAttackingState.csā has no access to āFighter.csā (at least āstateMachine.Fighterā), or a function known as āSetLocomotionState()āā¦? Because itās complaining about these two right now
Neither of these things would be normal, noā¦
In PlayerStateMachine, the declaration for Fighter should be
[field: SerializeField] public Fighter Fighter {get; private set;}
Meaning you should have read access, but you shouldnāt be able to change the value of Fighter (you can call all public functions and read public properties on Fighter, but you canāt say stateMachine.Fighter = something).
SetLocomotionState should be in PlayerBaseState.cs (Iāll edit that in the lesson, I think I neglected to mention it. If you recall from the Third Person Course (and at this point, I tried to stay as close as possible until this lesson to the TPC), SetLocomotionState (or it might have been ReturnToLocomotionState simply checks to see if we have a target in targeter and decides whether to return to PlayerFreeLookState or PlayerTargetingState
protected void SetLocomotionState()
{
stateMachine.SwitchState(stateMachine.Targeter.CurrentTarget?new PlayerTargetingState(stateMachine) : new PlayerFreeLookState(stateMachine));
}
fair enough, thanks Brian
There were some other variables as well that changed and were not properly mentioned, like the animation float trigger namesā¦ This one took me a while to figure out what I was doing to solve it (all is good now though). We all slip though, so itās okay
Iām about to start lecture 21, and so far Iām surprised we never added the attack arrays into the state machine. From a quick look, it doesnāt seem like the āPlayerStateMachine.csā script will be tackled in this lecture eitherā¦ - How do we get the player to actually play the attack animations and deal the damage though? Iām genuinely confused (so far if I click somewhere, he doesnāt attackā¦ he just freezes in whatever motion state heās in, until I lift my mouse button up)
This was quite literally being set up in lecture 19ā¦ We donāt add the attacks in PlayerStateMachine because this would make swappable weapons extremely difficult.
Attacks are ScriptableObjects, which must be created with right clicks like WeaponConfigs
The WeaponConfig contains an array of attacks, but for now, itās only considering the 1st entry in the attack
PlayerAttackingState gets itās Attack data from Fighter, if an integer is passed into PlayerAttackState (when we enter AttackState from a locomotion state) or Fighter is given the Attack data from an actual Attack reference (from the Attack combo field) if this is a combo attack.
When we enter PlayerAttackState, the last line in Enter() is a CrossFadeInFixedTime to the currentAttackās attack state in the animator.
OK Iāll give this a go and see how it turns outā¦ I was extremely confused as of whatās going on there, but I think Iām catching the idea now. Attacks donāt need to be in some resource folder though, unlike WeaponConfigs, right?
Thatās correct. In mine, I kept the Attacks in the same folder as the Weapon object just for convenience.
Remember that for combo attacks, youāll be putting in another Attack ScriptableObject. That Combo Attack does not need to be in the WeaponConfig at all.
For me, Iām placing them in a unique āAttacksā folder, that just contains folders that contain unique animations for each weapon (including the unarmed)
Quick question (and problem next) though: for the WeaponConfig attacks, we just add one attack, and that attack can have a trail of āNext Combo Attacksā, instead of adding them all, am I right?
And my problem right now isā¦ the punches donāt land any sort of damage (and tbh I might turn off the loop time/strip some animation times out, because some of them are extremely slow)
Yes, for now. The long term goal is to have some randomnessā¦ so you might have 3 or 4 starter attacks each with their own combo chainā¦ (of course, you have to have the animations to back that up). The last attack in the chain simply has no combo attack assigned.
loop time??? No attack animations should have looping or you wonāt be able to detect their endā¦
Did you add a TryHit Animation Event with a 1 or 2 for right/left hand?