Integrating the 3rd Person Combat Series into the RPG Series

OK so as the title suggests, I want to integrate my knowledge from the third person combat series into my RPG Project (I’m at lecture 61 as we speak, but I’ll probably be done with it before Brian sees this). I have to admit though, I do not want to integrate everything Nathan has taught us into my game, possibly just the third person view and the controls, and from there on I want to tune my own systems

There are some things I personally do not want in my game, or I want to modify them (I’m writing this as documentation, and can also use some help):

  • One of them includes his combat focus system being altered with a tab button (I want this to happen automatically, if there’s an aggregated enemy coming at us, rather than being manual, and the math will be done based on distance to the player BEFORE calculating the position of the nearest enemy to the center of the screen (so if no enemy you can see ahead of you is closer to you than the center of the screen, only then will you be allowed to focus on whoever is closer to the center of the screen. If there is one coming from behind, we can unleash a notification for that, probably through a moving trigger of some sort). Above all else, I’ll toggle this entire system using a boolean).

Somehow, somewhere down the line, my player became capable of self-targeting, and I’m still trying to find where this is coming from (in the third person course. PLEASE HELP)

  • The Ragdoll system: I don’t want this in my game for one simple reason: If I’m doing it for my player, there’s a good chance my players would expect this on my enemies as well… Let’s just stay out of this one for now, it sounds like a physics nightmare waiting to happen
  • The enemy AI (we have our own, and the weapons colliders toggling is causing me severe nightmares of missed hits)… I might want to integrate combo attacks for my more superior enemies, but we’ll deal with this later down the line
  • I do want the combo attack system, but instead of the player holding the mouse button down, I want it to rely on a timer between mouse clicks. So if you click ONCE, let’s say less than 1 second after your last animation was triggered, you go into the second attack of your combo sequence, and the same check before the third, etc… If it’s more than 1 second since the last hit, you restart the combo sequence
  • The basic movement can use a bit of adjustment. I’m not sure what it is, but this one feels a little bit…off (I’ll figure this out and update along)

So, without breaking my project, how do we start working on this? (I’m most concerned about the code consequences of adjusting the mover.cs script in my RPG project, since we’re no longer using the mouse button, and it will be replaced with buttons). I might have to re-code some systems though, as some of them just don’t work for some reason (and I’m in Unity 2021)

I’ll be honest, if you went through the course this quickly (you literally only started this week), you likely didn’t get everything you needed. In fact, you may have set the speed record for going through the course…

Instead of stopping along the way when you had an issue (the self targeting), you just headed on through. “PLEASE HELP” with what? I don’t know when or why or how you started self-targeting (or what you mean by self targeting? Do you mean that you’re targeting a character immediately without pressing a button or that you’re attacking yourself?)

First of all, let’s be clear, you are going to break your project. It took me quite a bit of time (a lot longer than your trip trip through the course!) to get the project back to a reasonably playable state.

The player will have to remove the Mover component, the Capsule Collider, as well as the NavMeshAgent. The Fighter can remain, so that it can handle weapon changes.
The PlayerController will remove the movement handling, and only test for IsPointerOverGameObject and IHandleRayCastables.
CombatTarget will no longer be an IRaycastable
IRaycastables will no longer attempt to move the player if the player is out of range. Instead, they will simply not function until the player is within range.

Once this is done, then you can start adding in the CharacterController, ForceReceiver and you’ll build the PlayerStateMachine up.

In my implementation, rather than turning on and off during the Attacks, I stick with the Hit() method, performing a SphereOverlap at the point of the weapon damaging any character that is overlapped. It’s more likely to get a hit than Nathan’s collider method (which will often miss if the characters aren’t close enough together without grossly exaggerating the colliders).

You just have to make an event for when the attack button is released (cancelled) and listen for it in your PlayerAttackingState(). If the player releases the button, then set a bool to indicate so. If the player didn’t release the button then fail the TryComboAttack() method.

Now here’s my advice:
Start this with a copy of the game where everything is already working properly. If you have a current issue with your game, gutting the movement system in the middle of it will likely create more problems than it solves. Ideally (and I’m really QUITE serious about this), you’d be using source control and create a branch at this point. Doing this without proper source control is a recipe for disaster.
Extra ideally: Go through the Third Person course a 2nd time, reviewing what you’ve learned and increasing your understanding of the system. Do you know why I can come up with some of the changes to classes as quickly as I do? Repetition. I’ve built the RPG project from the ground up four times and spent more time going through most of the individual components used in the project just by themselves longer than you went through the Third Person Course… I’ve built the Third Person course from the ground up twice, spending about an hour reviewing each lesson. It’s that deep dive into each lesson and component that builds that knowledge.

Well, when I press tab, my player detects himself as a target in ‘targeter’, since he’s one of the closest targets near the center of the screen

What I learned about myself out of this whole game development journey so far, is that I just take the knowledge, and attempting to manipulate it and re-program it is exactly how I learn. Eventually, everything falls into place and things make sense when I see the same thing over and over again in different shapes… So yes, I don’t mind going through the course all over again, but me knowing myself quite well, I can easily get bored of something if I don’t see the direction I’m heading through. Literally speaking, the only thing that’ll ever get me to understand the code is countless try and error, and whether you notice it or not, but the fact that you take hours to show up (I don’t mean this in any offensive way, please don’t misunderstand me) is extremely helpful… because it’s the tuning and manipulation of the script that always gets me to actually think it through clearly, and understand what’s going on (I literally started understanding the RPG Core Combat course code only through try and error… I’m not a master at it, but it’s the tuning that actually got me to understand what’s going on).

Anyway, I won’t argue, I will go through this course once more and see where I went incredibly wrong, and then follow with your instructions about how to implement this into the RPG course… I was a little too excited this time :sweat_smile:

So for now I’ll just try fix the issues I faced along the way, and then see how will I integrate this into my own project

As for my game issues, there are a few minor issues here and there, but hopefully they won’t turn out to be huge deal-breakers. I’ll play-test it once more thoroughly before moving on

And your player has a Target component because?

Ahh… I think I was testing something somewhere, where I tried changing something and accidentally forgot it there

ANYWAY, more issues in the Udemy Q&A Forum, I’ll go see what I can do about them when I’m done with this lecture (it’s the last one), before I hunt and fix my code in the lectures

I think the plethora of issues you’ve encountered in the Third Person course SINCE starting this thread underscores my suggestion that you wait until these are resolved and the course content is well absorbed…

I have resumed work on an integration tutorial, which is in progress, which is intended to get people through the Melee Combat section of the course (basically, for the most part, it follows the lessons, with “do this, not this”). It’s based strictly off of a clean copy of the RPG course, as this integration guide is intended for that purpose. I started this several months ago, and stepped away from it because much of my time was being spent covering out of course ideas… :stuck_out_tongue:

I’m working on it, but as it’s a free time thing and requires me to review the lessons, it may take a few weeks. It might make sense for you to follow this integration tutorial when it’s completed on a clean copy of the course (you can get that from our repo), and then start actual integration.

Fair enough, I’ll try as well on my side

Gotta admit though, my ideas make gameplay more fun :stuck_out_tongue_winking_eye:

Is it really that necessary to start on a clean copy? Most of what we integrated fits both 3rd person and point-and-click models, right? (Apart from animations, which we didn’t invest much into anyway)

I’m starting on a clean copy for the tutorial because it’s not just for you.
Starting on a clean copy when working through new material has two benefits:

  • We’re all on the same page if something doesn’t work, it’s easier to nail down if it’s an issue with the tutorial or an issue with your main project. When you go to integrate it into your main project, you have a solid working version on your computer to refer to.
  • It makes it MUCH easier to diagnose an issue. If there’s an issue I might wind up spending hours trying to find out what went wrong in my code when it turns out to be some component I don’t have.

Privacy & Terms