Actually, never mind that… you don’t deal damage until the Dealing Damage page.
I always LOVE hearing the word ‘randomness’ in game design… it just makes everything significantly less boring and more fun
I’ll probably throw in a kick animation into the mix
My bad, there’s no loop… I just thought they’re slow, so I 1.25x’ed their speed for now, and stripped some of the time off the animation out
Nope… did not do that yet, and I’ve finished lecture 21 (I thought it was called ‘ApplyAttackForce’, and which slot of the animation event takes in the 1 or 2, the integer, right?!)
For that, you’ll need to have transforms for the left and right foot, which I will be covering in a later unwritten lesson. Those will be TryHit(3) and TryHit(4).
so for the moment I’ll just be using the normal attack animations I got off mixamo, got it (surprisingly, Kevin Iglesias did not include any into the mix this time…)
Still, my doubt is out here. Is it ‘TryApplyForce’ or ‘TryHit’? and the float or integer (in the Event) takes the numbers? (I’ll take a wild guess and say the force is for weapons, and hit is for unarmed, and they all go into the integer… it just makes sense lel)
The ApplyAttackForce is for the movement forward, the TryHit replaces Hit. The parameter is the int index, which corresponds to the integer parameter in Fighter.TryHit()
void TryHit(int slot)
{
Vector3 transformPoint;
switch (slot)
{
case 1: transformPoint = rightHandTransform.position;
break;
case 2 : transformPoint = leftHandTransform.position;
break;
default: transformPoint = rightHandTransform.position;
break;
}
Debug.Log($"Attacking with slot {slot}, position {transformPoint}");
}
But even unarmed attacks get him to move forward, right? I’m sorry, I’m a little confused… ‘ApplyAttackForce’ is to push the enemy a few steps back, right?
I used the ‘TryHit’ in my animations, and it worked (for the unarmed), but… the hits sometimes miss the enemy due to animation rotations (I can’t always get those hands to land, because some of the animations are red light-ed after I trimmed some time down)
By the way, is there anyway we can disable combat if the player is not in target state? I’m not sure of the long term risks of that, but short term it just seems to make sense that the player doesn’t try do any sort of combat if he’s not in one
Yup, I found these and adjusted the inputs accordingly in my animation events
So now I just have a major problem with my player rotating away from his enemy, and potentially missing hits, even with the targeting turned on
(and if you recall our ‘Enemy Level’ HUD, which used to display the combat level of the enemy we’re about to attack, this one doesn’t detect him… It would be nice as well if we can turn this on once the player is in targeting state)
ApplyAttackForce is to move the PLAYER forward. Enemy is later. Any attack you want to push forward, add the ApplyAttackForce and enter the amount of force in the Attack. We’ll deal with enemy pushback later. Right now, with the enemies using the RPG logic, you CAN’T push them back. We need to convert them to StateMachines with ForceReceivers first. Long ways off.
Adjust the animation rotation in the import dialogue (animation offset). I scrub the animation to the hit point, then adjust the rotation offset so that the fist is now directly forward.
Easy, don’t check to see if IsAttacking is true in PlayerFreeLookState. Done. It’s in there because that was Nathan’s course design. Later in the next section, I will be using the IsAttacking to also pick up items if no combat is going on… just don’t attack.
well… now I just unlocked a new unique bug. If you try pickup the loot of the dead enemy, he re-dies and re-drops the loot
Welcome to another day of ‘infinity item drop glitch’
Anyway, let’s get the rotation right first, xD
Not a bug, you’re not to pickups yet.
And be aware, this tutorial is not complete, so there are going to be some things that don’t work yet.
Woop, fully aware of that. Just pointing out what I found as well - I’ll give you your time as well, since once I turn the character to a third person, I have other complex mechanics I want to integrate (and one of them is a construction system I found online… I figured this one will be hard to build, so I decided to use something that already exists)
One last question, I may have missed this out… but through code, is there anyway that prior to landing the first punch, we can introduce a function (to add as an animation event) that gets the player to properly rotate his fist (or weapon), and in return his entire body, to his enemy? I added the rotations to counter for the rotation between animations, but I think this one will be extremely helpful
Add this to PlayerAttackingState.Tick() just before Move(deltaTime);
var target = stateMachine.Targeter.CurrentTarget;
if (target)
{
FaceTarget(target.transform.position, deltaTime);
}
Yup, that worked insanely well. Thank you again Brian
last question, how do we reduce the time it takes to check for the mouse click to play the next animation? Feels like no matter how fast I click, I’ll always only play the first animation, with the occasional catch-up to the second one (apologies if this sounds dumb, I’m still trying to absorb what’s going on here)
Edit: After a while, I learned that holding the mouse button down plays the animations as long as the button is clicked… Personally, I like to click as well to catch up with the animations, but I won’t complain, xD
Not sure if I missed something, but I went through the Inventory lecture twice, and following the instructions to the brink… my Inventory no longer opens when I press the ‘i’ button… (and the same issue goes with the Pause Menu UI, and I’m personally skipping the Trait Window because… well… I’m using a Skills’ based system. If I’m being brutally honest though, I might skip the entire UI Control take over because mine is already fairly complex, beyond the main course… as you might remember, we developed solutions to shut down Shop UI when the pause menu button is clicked, or quest UI, etc… it’ll take a while to redesign all of that. What risks does this carry?)
and in the ‘PauseMenuUI.cs’ script in the Pause Menu lecture, what type of variable is ‘activeWindows’? I don’t think we defined that at the start of that script (if it’s the one in ‘WindowController.cs’, shouldn’t that be at least ‘protected’ instead of ‘private’?)
Another issue I have is that when the enemy is dead, if I punch within his body radius, he replays the death state, by giving me xp, more loot to pickup, and the death sound… Does this get fixed in the pickup chapter?
And my last doubt would be if we should change the ‘CurrentTarget’ in ‘RangeFinder.cs’ 's setter (Lecture 25/27) to public or not, because without doing so, ‘Targeter.cs’ complains that it’s inheriting a private setter and we’re trying to modify it
Edit: AND… The pickup code got my player to freeze when he’s in a fight for some reason. after the first animation, and the pickup didn’t work either, and I have no idea why…
Edit 2: I fixed the Attack freeze issue, it was because my Attack animations were not tagged “Attack”, after we changed the position of the ‘GetNormalizedTime()’ function in Lecture 26/27 (subtly, we also added the “Attack” tag request in there… I just didn’t notice it at first)
One last thing is more like 5 last things…
Then you didn’t set it up right… Did you create a button action mapped to I in the Controls? Did you add the relevant method in InputReader along with an InputEvent? Did you remove the ShowHideUI from the UI Canvas GameObject? Did you add the InventoryWindow script to the Hiding Panel GameObject?
If only I’d mentioned that in the tutorial… Oh, wait…
In TryHit, before damaging a Health, make sure it’s not dead first.
I’m using a similar, but more generic approach, and this entire conversion will take time, by the speed you’re gong through it, you’re missing important information…
Forgot to include to make it a protected set. It’s corrected in the repo. As a general rule of thumb, when you encounter something like this, check the repo. There may be a bit of code changed in another script that might solve the issue without making this Show topic unmanageable…
Then do the challenge on the Skills UI window. The point of the challenge is to reinforce the concepts from a difficult lesson. It’s very likely that the solution will be very similar to the TraitUI.
Yes
Also yes:
public event Action InventoryEvent;
public void OnInventory(InputAction.CallbackContext context)
{
if (context.performed) InventoryEvent?.Invoke();
}
The ShowHideUI.cs Script? Yes I did
Also yes
Eventually did that
Something like this line? It seems to have solved the issue:
if (otherHealth.IsDead()) return;
I put it inside the foreach loop in ‘TryHit()’, right before ‘TakeDamage()’
so the new approach keeps all the changes I did in my own code into consideration…?
Haven’t developed one yet, but sure why not (will do it after I fix everything else though). For now my main concern is why aren’t the pickup and UI buttons working
I’m not positive. It may need some adapting. My priority was preventing chaos while the windows are opened. Once again, I didn’t write this tutorial for your project. This is a tutorial on blending the Third Person Course with the RPG course. Most students won’t know a thing about changes to your project. This is a tutorial I promised students a year ago, long before all the changes to your project. That’s why I expressly recommended using the course repo version of the project, not your own.
Fair enough, which is why I wanted to skip the UI section overall, because it will cause chaos in my own project… at least for now
Anyway, if we can at the very least figure out why Pickup isn’t working, that’s more than enough for me today (P.S: I did the entire thing on the repo, nothing on my main project yet… I want to start that whenever this prototype works)