-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Npc behaviour Rudimentary setup #78
Conversation
Added a folder specifically for NPC's And created a very rudimentary NPC script. With a dialogue option
Updated Agent to include a isEnabled field. That prevents Root from running in update if disabled
Made a test NPC with a rudimentary behaviour tree.
It still requires that behaviour added in the behaviour tree but it will do for now
It is a simple script for now. I'd hope to program the movement scripts into generic behaviour nodes later. Still need to add: -Collision detection and avoidance -A follow path function.
Reformatted the old scripts to work with the new node system, created a basic follow player behaviour tree, and created a TestNPC companion in scene
This is the scene with the added testNPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff so far; I added some comments on specific areas that could be refactored (potentially in the future once further features are added).
The main thing to look into would be the object hierarchy and what classes extend what. We talked about it already in Discord but as a summary, there's kinda three distinct parts to note for this type of gameobject:
- Actor (and subclasses): Actors are basically any entity which should engage in combat / have a lifecycle.
- NPC: These are an extension of
Interactable
and are basically a fancy interactable that uses dialogue graphs. - Agent: Agents include any non-player object that needs a custom behaviour cycle.
I would ensure your NPCs have at most one of each of these types, depending on what their needs are. (I noticed while going through this that Interactable
actually extends Entity
atm, which probably doesn't make sense, so that may be something to refactor at some point also.)
Assets/Scripts/Game/NPCs/BaseNPC.cs
Outdated
public void TurnIntoEnemy(){ | ||
//Change to enemy Layer; | ||
gameObject.layer=LayerMask.NameToLayer("Enemy"); | ||
|
||
//Doesnt if this doesn't have Enemy Script will add it | ||
if(gameObject.GetComponent<Enemy>()==null){ | ||
gameObject.AddComponent<Enemy>(); | ||
} | ||
else{ | ||
gameObject.GetComponent<Enemy>().enabled=true; | ||
} | ||
//TODO add AttackBehaviour in BehaviourTree | ||
} | ||
|
||
public void TurnIntoCompanion(){ | ||
//TODO Make Follower movement, interactable | ||
npcCollider.enabled=false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I'm planning to have a "faction" system that we can use to help determine interactions between various actors (i.e. who is hostile to who). Maybe when we have that type of system, we'll be able to refactor this part into a generic ChangeFactionNode
behaviour.
Adds a node that forces the dialogue with the player instead of having that in the NPC behaviour script
Noticed that checkRangeNode implemented what I wanted already (may need to add both min and max values to checkRange later) but it accomplished what I want for now.
@TheArchitect4855 This PR is now ready for review! Unfortunately a bunch of sub-features and bug-fixes are tangled into it, so there's a lot to pull apart. Main things to focus on are:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at all those chickens! That's a lot of changes.
Looks good; I'm excited to see all of this new NPC stuff in action.
This is a basic NPC script along with a character in scene for people to work with. I'll be adding/pulling a character state system in place tomorrow for better management. I have a better plan to mannage character states (Enemy, Follow, Idle, Teamate etc) down the line but this should allow people to tinker with the current system tonight while add to it tomorrow. Any feedback greatly appreciated.