Merging the Third Person Controller Course with the RPG Course

If this part isn’t working, you’ll never get to the rest of the stuff, so we need to figure out why they’re not working. For example, telling me PlayerFacingState doesn’t work is meaningless because without a target, it’s never going to be called to see if it’s working…

So we need to figure out why the ConversantFinder isn’t picking up the Conversant…
Paste a screenshot of the ConversantFinder’s inspector…

That one was my fault. While most other code was direct pastes from Rider, I typed that one in off the cuff while typing the lesson and left out base.OnDisable();

Try checking “IsTrigger” on the Sphere Collider. Without it, you won’t get an OnTriggerExit or OnTriggerEnter messages, only OnCollisionEnter

I noticed you deleted the entire ‘OnDisable()’ function. I’m guessing I should do that too…

I definitely didn’t.
It’s not in the script posted before the virtuals were added, it’s in the snippet at the end of the DialogueUI section.

AND… THE WHOLE THING WORKS NOW

I still feel a bit weirded out by the fact that the entire game is stopping for Quests or Inventory Swaps… It just feels a bit off for me (I honestly want to delete that timeScale, but because the pause menu is also intertwined into this, it makes things complex for me…)

I mean… eliminating it did make this thing work tbh

If you don’t, the player is left defenseless or attacking when he shouldn’t be. I tried this in Spellborn Hunter and without the pause, the game was completely unplayable. You couldn’t get out of a dialogue fast enough to defend yourself.

Delete it, and then leave the Dialogue with Escape instead of the close button… Then put it back in when you see the glaring problem.

I mean… why even put Enemy NPCs in safezones in the game? Anyway… I’m still rethinking my approach to this whole thing

Well right now keeping it is giving me a significantly bigger problem… My game is FROZEN (that’s not an in-engine pause button click, the game is literally frozen as if ‘Time.TimeScale = 0f;’ was launched from somewhere). I can’t even get to the dialogue to begin with

I’m guessing it’s because I didn’t implement Chapter 27: Control Issues yet…?!

(Anyway, yup… I saw the glaring problem :confused: … and then I saw the updated line you added, which fixed the problem :slight_smile: )

Frankly speaking though, I still want my personal approach of getting the player into Targeting State, and focusing on the enemy, if he’s attacked midway through a conversation (so we are cancelling the Conversation, if he’s under attack… like we used to do with the old system), so that he kills the enemy first, and then he wants to return to the conversation. It just adds to that sense of realism in my opinion (I’m not going for AAA here, but I don’t want it to seem off-realism either), because you have to take care of your surroundings as well… Which is something I want in my game, that it doesn’t feel off tbh

Basically, I want to unfreeze time for all UI except the pause menu, and when we want to open up any of them, freeze the camera movement (by reducing it’s axis speed to zero, in the Cinemachine UI)


A new bug I just noticed, is when my player dies, his movement controls get deactivated… how do we fix that?

By the way, this is an add-on, and someone might find this helpful

If you want to split your Inventory and Equipment Window openers up, to the buttons ‘I’ (Inventory) and ‘E’ (Equipment), then here’s how I got it to work:

  1. In your Input Controls, add a new action, called ‘Equipment’, and assign it the letter ‘E’
  2. Place this block of code for it in ‘InputReader.cs’:
public event Action EquipmentEvent;

public void OnEquipment(InputAction.CallbackContext context) 
    {
        if (context.performed) EquipmentEvent?.Invoke();
    }
  1. Create an ‘EquipmentWindow.cs’:
using RPG.InputReading;
using UnityEngine;

namespace RPG.UI.Inventories 
{

    public class EquipmentWindow : WindowController 
    {

        protected override void Subscribe()
        {
            GameObject player = GameObject.FindWithTag("Player");
            player.GetComponent<InputReader>().EquipmentEvent += ToggleWindow;
            gameObject.SetActive(false);
        }

        protected override void Unsubscribe()
        {
            GameObject player = GameObject.FindWithTag("Player");
            player.GetComponent<InputReader>().EquipmentEvent -= ToggleWindow;
        }

    }

}
  1. Delete ‘InventoryWindow.cs’ from ‘Hiding Panel’, and place it onto your inventory instead, and then add the script we created in point number 3 to your Equipment Panel

By the way, something I did notice since we implemented this system, is that the movement saving system has become a total mess… In other words, everytime I reload my game, I always go to my player spawning point, not where I last saved my game… Were there changes in the JS lectures to address that? I assumed they didn’t change and skipped that part (AND… The player can move when he’s killed (until he respawns). Do we address that too?)

Most of these things you’re finding are because this tutorial is not done yet. I wonder if I’ve mentioned that or not… Player death will be coming soon.

Remove the Time.TimeScale=0 from WindowController.OnEnable(), then override OnEnable on the PauseMenuUI and and after calling base.OnEnable, call Time.TimeScale=0; You’ll also need to craft a different solution to the Control Issues lecture, or the player controls will still be frozen… Perhaps a boolean preventing the IsAttacking to fire when the windows are opened (or you’ll attack every time you click the UI)…

For the PlayerConversantState and PlayerShopperState, you’d need to duplicate all of the movement code, and detect when the targets are no longer in range (to close the windows appropriately).

At some point, I’ll make a Branch in the repo with these changes, but the main tutorial is going to continue to follow the model already in progress.

You mean that they’re NOT getting Deactivated, which is correct. That will be fixed in a later lesson.

Just making sure it’s a known error, not because of something dumb that I did… :stuck_out_tongue_winking_eye:

For the moment, I guess it’s best to wait for this… I don’t want to deal with any unexpected errors down the line and cause an even bigger mess in my project (I’ll just start taking notes of the changes I want and ask about them when this is done, for now I’m just gonna tag along. I think this is the best solution for the moment)

So it’s a known issue that after death, controls are turned off… got it :slight_smile:


How about the animator overrider? It will be fixed for animations to work with it down the line, right?

(because right now, the overrider does not override anything, even with all the proper variables assigned to each weapon… In other words, I can’t tune how my player acts when holding various types of weapons, neither do the swords play any sound that was assigned to them before the conversion)

(Just making sure I didn’t break any of that on my own :slight_smile: - because if I did, then I’m in trouble)

Literally the opposite of what I said.

This is an area I’m still working on. There are some inherent issues when swapping out animators/animator Overrides… The design I used for Spellborn Hunter has each weapon having it’s own proper animator, with certain “required” states and just the states required for that weapon for attacks. For this one, we’re going to be using nested Blend Trees.


As you add Weapons to your game, you’ll add a new Blend Tree to the master blend tree with the proper animations for that weapon. Then when switching weapons, we’ll change the numeric value of WeaponType (you’ll find that for many weapons, idle, walk, and run animations can be pretty universal). This will mean one Animator with no overrides.

Wait, so you’re trying to permanently disable the controllers of the player after their death, even after he respawns? (That’s what my game is currently doing…) What’s the point of that? (I’m not trolling, that’s literally what I understood) - because in my case, my controllers get permanently turned off when he respawns…

So from all of this, what I understood is that we should increment a value that will swap which variable the blend tree is pointing to, and all the blend trees for movement, per weapon, are all wired in the main characters’ new Locomotion State? Will a detailed tutorial be released about how to program this as well?

By deactivating, we’re simply going to put the player (or any dead enemy) in a Death state. Besides triggering a Death animation, this state will do nothing else, effectively disabling the controller. When a character is resurrected, it will manually be put into PlayerFreeLookState(), which will re-enable controls.

That about sums it up, and yes, there will be an extensive chapter on this. The biggest obstacle is working with the next to useless Mixamo movement animations (not a fan). Up till now we’re using the Unarmored animations for locomotino that came with the course. I’ll of course recommend using Explosive or Kevin animations…

There will be a chapter for this as well, Right?

Right meme

1 Like

Yes, although it’s fairly straightforward. In this case, the PlayerStateMachine listens to Health.OnDie (just like, you know, the Third Person Course), and we’ll need an event for Health.Reborn (or something along those lines, that the StateMachine will subscribe to to then put the character in a new PlayerFreeLookState.

for now I’ll just keep my eyes open for updates :slight_smile: (and Explosive is making a tempting offer to create animations for anyone who requests them, I’m taking him up on his offer)

Privacy & Terms