Merging the Third Person Controller Course with the RPG Course

One of the things often asked for by students in our RPG Course series and Third Person Combat and Traversal course is a way to blend the two projects together.

It is very possible to make this happen, but it is quite a bit of work. Far more than any one topic or post can do justice with.

What I’ve done is write a tutorial (well, still writing, but I’ve got things to a point that the Player can walk around through the world and attack, as well as open most UI windows and pickup objects off of the ground. There’s still a lot to do to blend the courses completely.

This tutorial will be hosted on my Wiki much like the Json Saving System. It starts with a copy of the RPG course as Sam left it at the end of the RPG series courses. We then work through changing the Player to go from the PlayerController to a PlayerStateMachine.

This tutorial is far from complete, but it is in a state where I can release the first section.

9 Likes

plays Silver Lining by Lights and Motion

It’s literally the only song I can think of to describe something I’ve been long waiting for :stuck_out_tongue_winking_eye:

On a serious note though, this one notification literally pulled me out of depression

hey Brian, first question from the get go. On the gitlab page, you did mention that we can use older versions. Unity 2021.3.21f1 LTS should be fine, right? (I’m lowkey terrified of using Unity 2022 for now, as last time it almost completely destroyed my project, and you might be aware now that my project is in deep advanced territory :sweat_smile:)

I recommend using a copy of your project, preferably something closer to the course project as you run through it. My best advice is to use the Course Repo version of the program.

This allows you to work through the course in a save environment, and then work through it again with fuller understanding when folding into your main project.

In versions before 2022.2, you’ll need to stick with the old NavMesh.

Other than that, I’m fairly sure most of the code I’ve used will work in Unity 2021.3.

so what changes do I need to be aware of for the NavMesh? NavMesh was where I initially gave up on 2022 back then, didn’t know it would be a big deal now :sweat_smile: (although considering that my Third Person project was done in 2021 LTS, it should be fine, right?)

And yes, like you suggested, I’m currently creating a backup of my project as we speak, then I’ll download a copy of the repo you provided. With that, I can perform safe tests there before going wild

After 2022.2, the “Legacy” NavMesh, the way it’s presented in the RPG course, is obsolete. This is the version where you open a Navigation Window and Bake the Navmesh.

The “new” version of the NavMesh has actually been in beta for… (don’t laugh)… about 7 years. It was available via a GitHub page, where you would add the tools to your project, and it replaces the legacy Navmesh. Starting with 2022.2, you have to add an AI Navigation package from the package manager to get the new NavMesh Tools.

They have some significant workflow changes. They are actually highlighted within the tutorial.

so to not screw my own project up in the long term, do you recommend I try going with the 2022 or 2021 version? personally I want to stick to the 2021 version just to avoid major issues, but I’d appreciate a professional’s response :slight_smile:

you asking me not to laugh made me laugh… :stuck_out_tongue_winking_eye: (thank you, xD)

In terms of your magnum opus, upgrading major versions represents risks. This is an area where source control is your friend (have I mentioned that before). Good backups are a distant seconds, but they work.

In terms of following the course, I personally recommend using the later version.

OK looking at all factors mentioned so far, I think the best idea would be to give it a try in Unity 2021 LTS, and if I get stuck I can ask questions, as I just don’t want to risk losing my project in a major accident down the line :sweat_smile:

1 Like

you really know how to cheer people up… :stuck_out_tongue_winking_eye: (thank you!)

but yes, I will use a copy of your repo project first, before I try anything stupid with my main project :slight_smile:

Umm Brian, is it normal for a URP conversion to take over 30 minutes…? (I’m still in the Initialization phase *_-)

URP failed on the demo project, time to restart the entire thing (after 29 minutes of waiting, I was getting no results :sweat_smile: ). So for me just to keep a documentary to myself, I’m skipping the NavMesh (I know I’ll regret this, considering what you said about hiding from bosses, but I also know extremely well I’ll seriously regret ruining my own project if things go wrong), and the URP Conversion

Overall, you can completely skip the URP conversion and just work with normal shaders. I only included it because the 3rd person course includes it. In fact, I don’t do anything else with it for the rest of the course. It shouldn’t take that long to initialize the converter unless you have like 10,000 materials… Something must have gotten buggy in the process.

Normally, when I start a new project, I begin with URP, and convert the Materials as I import each new asset pack instead of all at once. Converting the course project was a special exception. If I ever get the nerve up to rewrite the course, it will start in 2023, and will start with URP and the new NavMesh.

I’m sure that’s what happened :sweat_smile:

Please include networking as well by then, you have no idea how desperately I (and probably many others as well) want to integrate such a system into my game… It’s going to be a game changer :stuck_out_tongue:

Realistically speaking though, if I would’ve known URP was gonna play a key role, I would’ve integrated it from the start… I didn’t know much back then (and I still struggle from time to time)

ANYWAY, back to the course content :slight_smile: (so far it’s extremely well documented and very easy to follow, and I’m currently in lecture 11/37. Simply put, AMAZING JOB BRIAN. Thank you for being our saviour!)

I might open a new topic later on though, regarding the Cinemachine camera… instead of the camera going over obstacles or use the weird ways we set it up to deal with objects, I want anything the camera sees between the player and the camera itself to go transparent. I’ve seen this in games like Len’s Island, and I honestly dig this feature

Umm… Brian, there are some issues coming out of lecture 12: Force Receivers:

  1. In ‘PlayerBaseState.cs’, we got this line:
protected void Move(Vector3 direction, float deltaTime) 
        {
            stateMachine.CharacterController.Move((direction + stateMachine.ForceReceiver.Movement) * deltaTime);
        }

resulting in an issue that it can’t add two Vector3’s for some reason

  1. in ‘PlayerFreeLookState.cs’, this line in ‘Tick()’ is somehow complaining that it can’t convert a ‘UnityEngine.Vector3’ to a ‘System.Numerics.Vector3’:
Move(movement * stateMachine.FreeLookMovementSpeed, deltaTime);

I’ll try fixing this before moving on to lecture 14 (not touching the NavMeshAgent for this project) :slight_smile: - or until Brian sees this

Edit: Nevermind, I found the issue. Accidentally, I have placed the System namespace, and that confused the compiler. Removing it and leaving the “UnityEngine” namespace as is fixed the issue, my bad :sweat_smile:

and these are the ‘Character Controller’ parameters that got him to stick to the ground (I’m too lazy to accurately depict the values, but these work well for now… I’ll probably figure out how to slow him down and deal with animations down the line though)

and you also may want to reverse the ‘PauseMenuUI.OnDisable()’ time.timeScale value back from 5 to 1, it was driving me nuts for a while until I found it to bring the speed of the gameplay back to normal, for proper testing

and in lecture 17, the ‘TargetingMovementSpeed’ is in ‘PlayerStateMachine.cs’, not ‘PlayerBaseState.cs’, right?

One last question, when can we expect the update for enemies as well? (Not to sound greedy, I apologize if it comes along this way, I’m just curious so I know how to plan my game development schedule)

Make sure that in both cases, the following line is not in your usings clauses:

using System.Numerics;

and that instead you have

using UnityEngine;

Also make sure that your editor didn’t add

using Vector3 = System.Numerics.Vector3;

(this is a common autocomplete issue)

I actually thought I had, LOL. Anyways, you’ve cleverly figured out that issue. :wink: When we get to the Interaction section, this is going to be stripped out of PauseMenuUI anyways in favor of my WindowController.

Yes, Management is not responsible for typos on the part of an exhausted TA. Edit, actually looking over lecture 17, I am saying that I added the TargetingMovementSpeed to PlayerBaseState, but in PlayerStateMachine (and certainly that’s where it is in code, I just didn’t paste in the full PlayerStateMachine.cs when there was only one line of code).

It won’t be quite as quick as this one, and will be coming out a few sections at a time. I spent my Christmas vacation writing this while my lovely wife visited her oldest daughter. That kind of time with no TV, no interruptions from work, etc doesn’t come around often, meaning the rest will be slower going.

autocomplete sometimes is a joke… it creates its own problems, and then complains to me about it *_- ( :stuck_out_tongue_winking_eye: ) - still love that annoying thing though, xD

Most of the time I’m also trying to help. I’m sure they’re not there on purpose, xD

Don’t blame ya, I know you’re working extremely hard to make this the best gameDev community, and to be honest, you’re doing an amazing job (of all the developers I spoke to so far, you, the devs of the RPG course and bixarrio are my favorite!). Again, if I highlight something, I’m just trying to help :slight_smile:

Completely understandable, please take your time. In the meanwhile I’ll spend a few days properly implementing this and integrating a few systems I quietly developed :stuck_out_tongue_winking_eye: - it’ll probably take me a few weeks or maybe even a month (so hopefully that should be enough time), but it was extremely dependent on getting the player to work on being a third person controller (for now, let’s just make sure it works, because I’m in slide 18/27, and I’m still investigating why my targeter isn’t working, let alone the animations that are yet to be re-named… xD)

At this point, it’s pretty much the same as Nathan’s Targeter (It’s going to undergo some changes in a later page). Compare the settings on the SphereCollider and Rigidbody.

Went through it, still won’t work yet… For now I’m just assuming something is missing and proceeding with the tutorial till the end

Without it, the lessons on TargetingState movement won’t make much sense… One potential issue… if you’re using a sphere instead of an actual enemy for testing, the Health component also needs a BaseStats component or it will throw a null reference error.

I’m using a normal enemy. I turned off the rest and kept one on for testing purposes, but it’s not working yet. I’ll share a few screenshots of the recently added objects in the hierarchy, which I believe can be the reason for the issue:

Here is my targeter (which I created, but incomplete):

And here is my player’s currently updated settings, to get the targeter to work:

As for the enemy, I just added a ‘Target.cs’ script

I probably missed out something because I’ve been coding like a psychopath for 6 hours now. Whenever you have the time, can you please have a look?

and the compiler returns this error:

NullReferenceException: Object reference not set to an instance of an object
RPG.Combat.Targeting.Target.Awake () (at Assets/Scripts/Combat/Target.cs:30)

which also leads to this in ‘Target.cs’:

// CACHE
        private void Awake() 
        {
            health.onDie.AddListener(() => // this is the line the compiler is complaining about
            {
                OnDeath?.Invoke(this);
            });
        }

Privacy & Terms