AggroGroup for third person

I’m not going to do it. The AI required to prevent this from becoming a battle simulation is not something I want to get into. It’s not difficult to get the idea working:
Give enemies factions and if the damage dealer (I believe there should be something like that - instigator or something) is not in the same faction as the damage taker, set it as the damage taker’s target. They don’t have to stay angry at each other (or each others’ factions) because they’ll fight until one dies: Justice served. Return to hunting the player.
But, the AI would become a little more complex because enemies (especially ranged enemies) would have to start trying to avoid other targets to get a clear line-of-sight. Else you’d just be watching a bunch of enemies fighting each other all the time. Minecraft also has a thing where only the first hit character takes damage - unless you have the ‘Sweeping Edge’ enchantment - so even if the player is surrounded by enemies, if anything swings a sword and hits the player first, none of the other mobs are actually affected by it. Helps reduce the amount of enemies fighting each other. They actually do a good job with the AI so you don’t see enemies fighting each other all that often.

Blocking would be another beast altogether because this would require enemies to make even more complex decisions. Otherwise they may just block all the time and never resolve the conflict.

by factions, you mean the AggroGroups? Sorry, I’m not familiar with this term… I get the general idea though, and with everything I learned so far, I don’t think I can fully pull this off, but I can try and ask very specific questions when I get stuck :slight_smile:

[IGNORE, I’M LITERALLY JUST RANTING ABOUT HOW I SOLVED MY WORST PROBLEM TO DATE, ON A TOPIC I OPENED ON MY OWN]

Rant about my swimming state, part 2 (this is completely pointless, but I’m ranting here because fixing this is not perfect, and was aggressively harder than I thought it to be)… So here’s what I did

In order for me to get on a boat, I used a RangeFinder, just like any other solution like Resource Gathering, Crafting Tables, Conversation with NPCs, etc…

Now, getting on to the boat from land was no big deal. Just find the boat, hit the “F” button and get on the boat, and everyone is happy

Getting on to the boat from the ocean, however, was a complicated one, and here’s why:

When I was developing my swimming state, I had 4 different states:

  • The Swimming State. In this state, you’re just swimming and turning around, no biggie
  • The diving state (using the control button. Not a seperate state, but it has it’s own buttons in the Input Controller… but it’s taken care of in the Tick of the Swimming State. In short, you can dive underwater by holding the control button with this one)
  • The reviving state (using the space bar button. Similar to diving state, it’s taken care of whilst swimming. However, this one was a complex one, because when you’re reiviving, the player doesn’t know when to stop reviving. This means that I had to place an invisible box collider on top of his head when he’s reviving, to ensure he doesn’t revive his way to space, and it will get deactivated when the space button is let go of… it’s only accessed from the swimming state as well, so this makes life easier when you’re out of the swimming state. The big problem is, because we were brutally stopping him with that box, when you get off driving the boat, he will want to try to fly into space to cover up for what reviving did to him)
  • And finally, the player sprint swimming state. Again, taken care of whilst swimming, and has its own individual buttons (left shift for my case, whilst swimming only)

All these states have their animations taken care of in a blend tree. I’m not getting into this here

So my problem was, as mentioned before, because my revive to entering a boat is not a friendly solution, I had to think of a different one. So here’s what I did (drumrolls please):

Remember when I told you earlier that the RangeFinder finds anything? In order to find the boat, you need a boat box collider on it. So what I did, was use that box collider’s trigger boolean to mess with it.

  1. First, I developed a boolean function, and it checks if the player is close to the boat or not, by getting the Vector3 distance between the player and the boat, and compare it to a threshold I setup as a hard-coded 2f (because any higher than that, and you’ll end up immediately getting back on to the boat the moment you jump off the boat into the ocean), and if he is, we will act accordingly.

  2. If the player was reviving and he was close to the boat (check 1, the “IsCloseToBoat()” function), turn that trigger off so that it becomes an invisible box collider. That way, he won’t be able to get close and collide with the boat’s colliders, or enter the boat when reviving. These were the two main reasons why the player would fly to space when he gets off the boat driving state that he either accessed from colliding with the boat’s mesh collider, or from entering from his reviving state

  3. If he wasn’t reviving, I developed another function that AUTOMATICALLY gets the player to get on the boat when he’s close enough. That way he will have zero chances of colliding with the boat and somehow ending up flying in space

  4. Unfortunately I can’t think of a solution that does all of this in the Tick method, so I used an event that was subscribed and unsubscribed to in the Enter and Exit states of the Swimming state of the player

And that’s about it…

I have to mention though, this is all a nightmare because the Boat’s mesh collider was a terrible one, so I had to use invisible planes and brutally force the player to stand on it when he drives the boat. I’m sure that would’ve been easier if that mesh was cleaner

Is the solution perfect? Probably not, because getting it all done in Tick would’ve been in ideal. But hey, I’m more than happy to get my players to step back a few steps and come back without reviving to get on the boat than have to deal with that annoyingly hard bug…

Thanks for reading my rant that was placed on the wrong topic :sweat_smile:

Just do me a favor and don’t try diving under the boat and then mounting it… it’ll glitch out on jumping, and you’re just nitpicking at that point in time. I won’t fix that anytime soon, my brain is steamed out after that one (although expanding the y-axis of the box collider, and an or statement on a function, seems to get rid of that one… I ended up fixing it anyway :stuck_out_tongue:)

the only thing I got so far right, is finding exactly where to search for whether the enemy should strike an enemy or keep aiming for the player. It will be in ‘Fighter.OnTakenHit’, a function I once created to activate automatic attacking when the project was still a point-and-click, which is subscribed to ‘Health.OnTakenHit’

However, I have to tune the enemy chasing and attacking states now, so that he knows whether he’s searching for a player or an enemy, depending on who hit him, and that’s a scary area for me to investigate (again. I just gave it a go, and doing so glitched my player so he no longer dies…). @Brian_Trotter any thoughts about this one?

I may have mentioned before the tendency of adding on new features while you haven’t got the underlying features working properly leading to issues that become extremely difficult to diagnose…

At this time I have no plans for enemy jumping. I’m already behind my schedule for this tutorial, which means that my Saving System standalone tutorial is likely not going to be completed on the timetable I intended.

Not really… Think of World of Warcraft, which has many factions… The most well known are the Horde and Alliance, but within those factions are more factions (Orcs, Trolls, Forsaken, Blood Elves, Goblins, Humans, Gnomes, Dwarves, Night Elves, etc). Each of these factions have a relationship with one another that determines a number of game mechanics… If you are hated by Humans, they will always attack you on sight. If you are revered with the Orcs, they won’t attack you and will sell you fresh spider kebobs for a healthy discount.

Of course, it doesn’t have to be that complex. In it’s simplest form, it’s a way of quickly determining hostility. In Spellborn Hunter, I have several factions, and a given character can be one of:

  • Bandits
  • Player
  • Guards
  • Animals
  • Undead

All but the guards are hostile to the player
Undead and animals are hostile to everybody
Guards and Bandits are hostile to each other.

And yes, this does lead to characters fighting each other instead of the player.

See above comment about trying to do this while you have A LOT OF OTHER ISSUES GOING ON. One of the reasons it takes 60-300 posts on a topic to fix an issue (when the average Ask topic is 5 posts) is that your code is all over the place.

OK… Kinda true :sweat_smile:

I can give this one a go down the line

I know we said no adding new topics until we get the tutorial done and my issues fixed, but come on… that sounds like a ton of fun and liveliness brought to the game (but fine, I’ll be quiet… I’m just trying to do something else until the Projectile tutorial is out (today? tomorrow? next month? :stuck_out_tongue: - P.S: I’m just joking))

Privacy & Terms