Search Unity

Third Person Controller - Third Person, AI, Multiplayer, Mobile Framework

Discussion in 'Assets and Asset Store' started by opsive, Jan 21, 2015.

Thread Status:
Not open for further replies.
  1. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Also, here is some weird enemy AI behavior where it just stays in one spot running over and over but not moving. I attached a low-rez video, let me know if you would like to see a higher-rez version.

    The behavior occurred when I didn't touch any controls and let the enemy AI kill me over and over and over until this bug occurred.
     

    Attached Files:

  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    When I created this tree I was originally thinking that it just be a small sample tree used to show the integration with Behavior Designer, the Movement Pack, and the Third Person Controller. This tree really did not take much time to create and I think that you are right in that I should put some more time into it. Especially since I am going to be using it to promote both assets. I'll make another post when I am completely happy with it :)
     
  3. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    yeah the ai needs a good bit of work before it can be of any use (sorry for harsh post)
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Tough audience ;) But it's all good feedback and I really do want to hear it so thank you. I'll improving it tomorrow.

    This has actually been a good exercise for me - most of the integration sample scenes created for Behavior Designer have been relatively small and just showoff the bare-bone functionality. It really tells me the types of tasks that I need to create for the Third Person Controller.
     
    Last edited: Feb 16, 2015
    daisySa likes this.
  5. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    i dont think its important that you provide a fully completed AI setup, every project would have different needs, but providing few action and condition would be enough for each one to build its own setup
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That was actually my original thinking. But I do see @eridani and @im's point.. If I am going to be using this demo for Third Person Controller (and Behavior Designer) promotion it at least shouldn't have any bugs. I am going to work on the problems pointed out by @eridani and add a branch where the AI searches for the player after losing him. I don't think either of these will take too much time so it is worth doing. I am also planning on using this tree as a Behavior Designer learning resource by recording a video and writing documentation on it so there is even more of a reason to add polish.

    For some Third Person Controller specific news.. Adventure Creator integration will be added as soon as I get this tree improved and documented :)
     
  7. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi hi, Tiny point about the adventure demo.
    Run up to a wall, jump "at" it, keep pressing forward, you will "Stick" to the wall.

    Just a "named surface" issue or something.

    cheers.
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks! Yeah when the character is on the ground he should be using a friction physic material and when in the air it should be frictionless. These values were flipped for the adventure scene.
     
  9. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    actually getting a realistic working ai is selling point for behavior designer asset. cause then people will buy the behavior designer for the working ai, people will buy it to tweak the ai, ect

    also it would be good to have like behavior designer runtime (without the ui designer) that you would give out with 3rd party controller or as part of its own asset with working ai (canned real world behaviors that you would create for people to use out of box) this could be product by itself

    so you have the controller, the designer, the behaviors

    the controller could come wiht like behavuir runtime and sample behavior ai, the behaviors would come with behaviors and behavior runtime and sample that use them and then the behavior designer would be like the editor. there could be like package that has them all


    hope this helps and i think this would help people trying to get into unity to be able to buy out of box working solutions i think this where u heading with the 3rd person controller.

    also check UAS there is rival theory, https://www.assetstore.unity3d.com/en/#!/publisher/502, they doing rain and character that come with characters with out of the box working ai. but i think people more interested in hooking up working ai to their characters, not buying someone else characters.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    You definitely have the right idea with where I am headed @im.

    I just finished uploading a new version of the AI demo. The AI is now a lot smarter and it works pretty well. All of the problems mentioned by @eridani should be fixed. Here's a link to the AI Demo.

    Similar to before, the soldier will go get health or ammo if he is running low. The part that is different is how the soldier reacts to seeing the player or getting shot. Pretty much the rest of the tree is different. When the soldier gets shot at he will move to the player's position. If the player has hidden since shooting at the agent the agent will then wander for a small amount of time before patrolling again. If the agent does see the player at the last known location he will begin shooting at the player and will keep tracking the player for as long as he can. Whenever he loses sight of the player he will start to wander at the last known location. Here's a picture of what the new tree looks like:

    Patrol.png
    As always, I'm interested in hearing what you think. I'll wait a day or two before I start to work on the documentation just to be sure the AI works well. I also have not updated this version to the Behavior Designer samples/integrations page yet.
     
    twobob likes this.
  11. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    new release is like 99% there


    three things

    1. still having small issue activating platforms (perhaps its just small bug)

    if platform is on ground floor and i go to top floor the panel does not let me activate the platform so that it will come up

    i think the same is also true if the platform is at the top floor the ground floor panel will not let me activate the platform so that it will come down

    the only panel that appears to work is at the platform and that is still a bit trick to get activated (perhaps increase radius or collision area)


    2. ai does not have concept of hearing. so i can go up to the enemy npc form behind or sides without them noticing me at all. please add concept of hearing and it should be radius so if im a floor below and i shoot it should hear me and come at me. the same for if im behind and i get to close it should turn around and come at me or at least turn around and start shooting

    also ai missing concept of peripheral vision so its not just like ray but vision cone and sound cone


    3. icing on cake when i get hit or when enemy get hit we should react by making hurt sound and have like some hurt blood effect and body should react like by jerking.


    i think once you have like the above done its like aaa ready since it like takes into account just about everything i can think of.
     
    Last edited: Feb 17, 2015
  12. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Effects like sounds and splatter are ten a penny. That kind of stuff is really "student exercise". However a placeholder sound and particle effect trigger would not hurt to demonstrate the best-practice "Activation logic" paths.

    The hearing stuff is pretty much just a proximity-based activation with a conditional "level" based filter.
    It would be good to link it to a Sneak state to demonstrate multi-state logic to again demonstrate best-practice.

    Excellent work on this sir.
     
  13. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    This is getting serious :)
    Very good for a 3rd person controller demo, but since you asked about our opinions on the AI, I'd like to say a few things;

    - Turrets don't see me as a thread and don't fire at me, which is a shame, because I'm there to kill them :)
    -Soldiers run for health pack alright but when he needs a second one he goes to health pack location and waits to be killed :)
    - If I shoot a soldier from an upper floor and jump down as he tries to reach me. He goes to my last location and I can easily kill him on his way (he just walks straight to my location, open to abuse)
    - Also sometimes soldiers don't shoot at me but my last position on some cases.
    -Elevator seems like a safe zone; I shoot an enemy(he follows) an went up to elevator, he comes near me, we start chit-chat :) until I kill him of course.

    Thanks for asking our opinions to make this better Opsive!
     
  14. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I managed to break the AI by hiding behind a box.

    They just kind of "came near" me but showed no agression, I tried to walk away but the motion kept dragging me back to the spot where I had taken cover, without me even pressing any keys.

    Then, later on when I came back to screenshot, they had all entirely stopped moving.
    I could still move however. Weird ey :)

    Picture: They are actually stood frozen like that. My guy can move but if I leave I get sucked back to that spot.
    Glitch

    frozen.JPG
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks for all of the feedback! I'll do another pass on the AI and add the ability for the soldiers to be able to detect audio. I'll also take a look at the bug reports. In terms of reacting when the agent/player gets shot - yeah, that would be a good addition. I've written it down and should be able to get to it within the next couple of Third Person updates.

    Tricky Tricky ;) I have an idea on how to solve this, we'll see if it works..

    Did this happen with the web demo or your own build? The only reason I ask is that I see Development Build on the bottom right of your screenshot and I haven't uploaded this new behavior tree yet.

    Based on that screenshot, it looks like the RigidbodyCharacterController.Move method isn't being called. The Behavior Designer - Movement Pack integration adds the component that calls this method, and it should be called every Update tick but it doesn't look like it is. Move will eventually update the Animator which it doesn't look like it is doing.
     
  16. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    @opsive did you managed to make the AI + pathfinding working with root motion?
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Yes, though just AIPath. This is available on the Movement Pack integrations page. Here is a link to the documentation as well. I attempted to get RichAI to work but RichAI wasn't built with extensibility in mind. In order to get it to work you need to make some manual modifications to the RichAI class and I wanted to stay away from that so it would work out of the box. If I get enough requests for it I can take another look at RichAI and write a short tutorial on how to get it to work. I stopped when I saw the only way would be to change the class.
     
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    It was just the old webplayer.
    Will wait and test when you are good and ready.
     
  19. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    AI looking much better =) But still seeing this issue:

    when the enemy AI is attacking the player and the player simply moves behind the enemy, the enemy AI loses all awareness of the player.
     
  20. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Also, if I move the player back about 20 feet, the enemy AI stops attacking and starts patrolling again, even though he's looking straight at the player. It's like the enemy AI can only see 20 feet straight ahead. I think line of sight should extend much farther, especially when the enemy AI is attacking.
     
  21. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Finally, while on the ground level, the enemy AI will randomly stop chasing and/or attacking and sprint up the stairs.

    The enemy AI will sprint back down a few moments later and then repeat the whole thing.

    Maybe it is running to grab ammo or something? I'm not sure.

    I think there should be an option that once the enemy AI "locks on" to to the player, it should not ever run away from the player. Perhaps infinite ammo will do the trick.
     
  22. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Other issues:

    1. Do enemy AI use IK? They cannot seem to aim up or down.

    2. The player camera shakes violently and the player "flickers" when standing with my back to a wall. I think the camera wall collision detection needs some tweaking.
     
    Last edited: Feb 18, 2015
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks @eridani!

    That's right, the Can See Object task is probably using too low of a view magnitude value when the agent is attacking.

    You are right - I think he is going to grab ammo. I like the fact that he has to grab the ammo but I'll increase the amount of ammo that he grabs and the amount of ammo that he starts off with so he doesn't go get ammo as often.

    1. That sounds like a good task addition. Right now the agent will always rotate to face you but you are right in that it doesn't adjust the arms at all.

    2. I noticed this as well when I was testing it. It'll be fixed in the next update.
     
  24. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    The thing is, sometimes the enemy AI shoots only once or twice before running away. Sometimes he doesn't shoot at all, just starts running toward the player and then suddenly running up the stairs.

    So I'm not sure it's strictly a grabbing ammo reaction.
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The AI Demo page has been updated with the new behavior tree. I added the ability for the agent to sense audio and fixed most of the bugs. There are still a few outstanding but those are more general Third Person Controller related so I'll have it fixed in a bugfix release this weekend.

    First off, here's the tree:

    Patrol.png
    If you compare it to this tree you'll notice that it is more horizontal and doesn't contain as many deep tasks. In the previous version I was using an external tree so the same attack logic was used when the soldier saw the player or was shot at. With the addition of audio I decided to simplify it so only the Can See branch does the attacking - after all, the soldier isn't going to actually shoot unless he can see the player. External trees are still used (in fact 8 external trees are used) but they are used to allow different the different solders to have the same functionality.

    The audio sensing is a pretty neat addition. There is an audio threshold on the Can Hear Object task so if the sound is from too far away the agents won't hear it. It is now a pretty common case to be shooting at one solder and his buddy comes up to help out because he heard the sound. You also are not able to sneak up on the soldiers anymore.

    In terms of bugs that haven't been fixed yet, I still need to look at that camera bug when you back up against a wall. The soldier will not aim up or down yet either - I am planning on reworking the aim IK so when I get that done I'll add a task for it. @twobob I wasn't able to reproduce that hiding behind a box bug - let me know if you can still trigger it.
     
    Last edited: Feb 19, 2015
    twobob likes this.
  26. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay , I swear I didn't set this up. (Have a witness), went to the box, hid, Soldier ran around the corner and started cuddling me! (Although may have slightly photoshopped it)

    BuggySoldiers.jpg

    He is still there now...


    Harassment.JPG

    I am advised I may have a case for harassment, We have decided to give up this whole soldiering lark and go play poker every Wednesday
    :D
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    :D

    I'm not sure I even want to fix that ;) I've gone to that cover spot about 10 times now and the soldiers shoot me. They obviously like you better.

    When you spawn do you just run up to that cover point and the soldiers start hugging you? You don't have to do anything else? I'm also still wondering why the web player says development build for you - I don't have script debugging enabled. Just to see if you are using the latest - if you shoot immediately after you spawn the first time, does the top soldier react? Don't actually shoot the soldier, just shoot in that general direction.
     
    maddieScarbrough likes this.
  28. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Being extremely guarded about my phraseology here. I have indeed killed or shot soldiers then done it. That time I just shot someone a few times on the way down, looked around the corner, saw him coming, ducked behind and took cover with F, he ran around and hugged me, no aggression just sucked up right next to me and wouldn't go away.

    I never closed the webplayer as it goes, just checked back, he is still stood there, I accidentally shot him in the face, he cuddled me tighter? Pictured heh. Oh please someone kill me for all the double entendre in that, I did my best.

    InTheFace.JPG

    Dunno mate. Maybe he is a conscientious objector, It happened in Tron you know. SKYNET here we come!


    EDIT: Okay more seriously he did eventually fire (albeit not actually "at me" but off to the right a bit) when I got out of the way. So perhaps you need a "Shoot" preference over "Arrive At target" since he was probably still "travelling"?
     
    Last edited: Feb 19, 2015
  29. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Hey twobob and opsive,
    I don't want to speculate on what's between twobob and that soldier fella :)
    I just want to note that, I also happen to see "Development Build" written on my web player and when it starts, I just shoot near him and he reacts.
     
    twobob likes this.
  30. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Dev build is your release channel, think its Alt + Right click then choose non-release channel, it will reload.
    No more message.

    In the end he broke my heart and went off with an automated floorbot.
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I'll keep trying to reproduce it but this bug has provided a bit of entertainment so I'm not completely against it. I will prevent it from happening as soon as I can though :)

    Thanks, I didn't know that - I assumed that it had something to do with enabling script debugging when making the build.
     
  32. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    You could release this as a Cuddling AI add-on pack. Could be useful for Sims type games :D
     
    maddieScarbrough likes this.
  33. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    AI looks even better than before. Almost like an AAA title. I had 2 soldiers chasing me all over the map, and they wouldn't give up. It was awesome.

    However, it seems like they will still run for ammo drops after a couple shots sometimes.

    As a workaround, is it possible to put a setting where they never run out of ammo? I don't want enemies running out of ammo in most scenarios anyway.
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Perfect! :D
    :cool:
    It is definitely possible to set infinite ammo for the soldiers. You can either set it per weapon (on the ShootableWeapon component) or for all weapons (on the Inventory component). You are right in that with most situations you probably don't want the agent to run out of ammo so you could completely remove that seek ammo branch from the tree. I want to leave it in for this demo though just to give an example on how you would accomplish it. I plan on using this tree to give an overview on one way to create a behavior tree.
     
  35. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    You've unloaded your gun on to his face and yet you expect him to make you a sandwich?!?

    I demand Sigmund Freud's view on cuddling AI and all this thread :)

    Back to topic;
    AI improved a lot. You said you may add shooting upper/lower levels. Do you also have plans to add AI that hides and shoots?
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I am planning on adding a new AI pack to Behavior Designer similar to the Movement Pack, except this one will be focused on tactical situations. Think flank, call for help, formations, etc. An AI that hides and shoots would be perfect for this pack. I haven't completely fleshed out what tasks will be included in this pack so I'd love to hear any suggestions. It will probably be a few weeks before I am able to get started on it though.
     
    twobob likes this.
  37. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    The tactical ones you mentioned would be wonderful to have. Not sure if I can add to those but here are a few suggestions;

    -Alerted / alert others (hears a sound but doesn't see. May transition into Seek or not)
    -Cover Me!! (Like in the movies; one AI in a group tries to get closer to player while others shoot furiously at the player)
    -Defend a position / player or other AI.

    for Third Person Controller;
    -Any kind of state awareness; AI vs. AI and AI vs. player (Climbing, Ragdoll, Jumping ,Dying , which tree is it using?)
    -Look/Call for item/help (AI might be alone or belong to a party. It might shout for others or might do his deed by himself)
    -Give/throw item (Give ammo to other AI or throw grenade to player ) (Handles both the action and inventory management)
    -Attack (Attack may have range (Melee, short, mid,long range...) and type (grenade, pistol) and handle inventory)

    All those can already be achieved using nodes that comes with BD and Movement pack.
    I guess, they would require a lot of nodes and vars to get there.
    I thought, you might wanna look through the list with 3rd person controller in mind. That might give us some more focused nodes.
     
  38. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    "Select best cover" not just the closest to the AI when it comes under fire. Similar to the above "Cover Me" however it actively seeks the best tactical position based on team positions when under pressure. Not just run to the nearest box.

    "Covertly stalk", why is it in all AI once the player is "Seen", they come running. It's also just as likely a combatant will casually wander away round a corner and dive on the radio for help. Much less likely to get shot in the head this way.
    Calm under fire. After this point (leaving the players line-of-sight plus 10seconds) all AI are aware of the players position and covertly take the best tactical positions for an ambush. How cool would that be.

    "Reaction Times" veteran soldiers can react in 3 seconds whether or not they just swallowed a flash bang, noobs are more like 15, the average person would wet their pants and gibber. Mix up the level of the AI based on real-person reaction differences to give a sense of varied skill. Put an amusing 3d label above each heading showing skill levels for extra coolness. This could be linked to health... "Elite Veteran" "Sergeant" "Private Average" "Noober" "Wounded" "Near Death" "Total Failure as a soldier"

    With such possibilities as "Near Death Private Average " and "Wounded Total Failure as a soldier"
    Which would be both amusing and educational.
    Stuff like that.
     
    Last edited: Feb 20, 2015
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks for the task ideas. I'll take another look at those posts when I get started on the pack.

    This sort of sounds similar to the Personality Traits asset that @TonyLi is working on. I was planning on integrating it with Behavior Designer when it came out because the two assets would fit very nicely together.
     
    twobob likes this.
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,698
    Development got sidelined for a bit with IL2CPP issues with the Dialogue System (Apple kind of put Unity in a pinch with the 64-bit requirement), but those are all straightened out, so the new asset is coming soon! :)
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Just a quick heads up that a new version of the Third Person Controller will be released as soon as it finishes uploading. This is mostly a bugfix release relating to the issues found with the AI demo scene. You can see all of the fixes here.

    The next release should contain some more major features/fixes.
     
  42. LightSky

    LightSky

    Joined:
    Aug 12, 2012
    Posts:
    45
    Is this compatible with any networking solutions as of yet? Or would it be rather easy to integrate it our self? As in not having to hack it apart like UFPS which required a networking addon just to integrate multiplayer.
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Currently it is not compatible with any solutions but it is in the short term plans. We are probably two or three updates away from being able to start on it. Ideally I'd like to use Unity 5's networking layer to prevent it from relying on any third party assets.

    I definitely don't plan on having to have another addon asset just to integrate multiplayer. It was really easy to add AI to it so I'm hoping networking will be the same. In this post Edgars said that it looks like it wouldn't be too much work to add Photon to it, though based on that post it doesn't look like he actually added it.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    We've been working on the next version and it should make adding new abilities really, really easy. In the current version just the cover and interact system are considered an ability. This has now been extended to include anything besides basic movement. Jumping, falling, crouching, and sprinting is now an ability. Don't want your character to be able to jump? No problem, just don't add the Jump ability. In the previous version if you didn't want your character to be able to jump you would set the jump force to 0. Now when you don't add the jump ability the jump code won't even be compiled with your game so it makes everything really neat. The additional benefit is that the jump code is in its own class so its easy to customize and is very modular.

    Here's what the current ability inspector looks like on the RigidbodyCharacterController:

    abilities.PNG

    The UI was built to be more functional than pretty right now so it'll probably change some before we release this update. You'll notice on the bottom right of each ability there is a -/+ sign. This determines the priority that the ability has. For example, falling is the most important ability so if the fall ability decides to start it will stop all of the other abilities. The system is setup to be able to handle concurrent abilities as well - for example, you are still able to take cover and crouch.

    On other neat thing about this system is that it makes setting up the animator even easier. Here's a picture of the new jump animator:

    jump.PNG

    Notice that there aren't even any transitions going from the Any State to the various states. This is because the RigidbodyCharacterController is using Animator.Crossfade in the background and it makes transitioning to different abilities trivial.

    Here's another animator example, this time with cover:

    Cover.PNG
    There's no need to transition from the Any State or a higher level state with this system. It is working out really well and the animations should be a lot smoother as a result.
     
    theANMATOR2b likes this.
  45. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    So if I want to add a "Dodge" ability I would make a script that derives from a Base Class and it would end up in that list. I set up my dodge however I want inside my dodgeAbility script. Later I would need to add my dodge related animations to into a new layer on the characters Animator. Is that it?

    But how my ability talks with other abilities would be another story. How it interacts with rigidbody..etc.

    What if I want this ability to be driven by Behavior Designer; DO we need to create a custom BD node that uses Third Person classes? or are there any planned nodes for BD that triggers any ability?

    All this looks very neat indeed :) No need to ask, I'm sure there is already a planned tutorial page or a video coming up because you are that much nice people.

    Any changes to the camera system in this update?
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Not necessarily a new layer, more like a new sub state. But the rest of it is correct. You could add it to a new layer but then you have to deal with making sure all of the animations are overridden correctly. Here's a screenshot of what the base layer looks like right now:

    base.PNG

    The base class that the abilities derive from is just a MonoBehaviour so you can interact with other components like normal. The base class already contains a reference to the RigidbodyCharacterController and Animator so you'll need to get the component for any other type. You can also use the event system to indicate that an action took place. For example, the cover system has higher priority than crouch. This is to prevent the crouch animation from taking over while in cover. The cover ability has its own animation for crouch so the cover ability needs to know when to crouch. Crouching is considered a concurrent ability so it can run at the same time as any other ability. When the crouching ability starts it'll send the event:
    Code (csharp):
    1.  
    2. EventHandler.ExecuteEvent<bool>(m_GameObject, "OnAbilityCrouch", true);
    3.  
    And the cover system will respond by changing states:
    Code (csharp):
    1.  
    2.   /// <summary>
    3.   /// The crouch ability has started or stopped. Change cover states to reflect the change.
    4.   /// </summary>
    5.   /// <param name="crouch">Did the character crouch?</param>
    6.   private void OnCrouch(bool crouch)
    7.   {
    8.      // Adding CoverIDs.CrouchStill will toggle the state ids between standing and crouching.
    9.      m_CurrentCoverID += (int)CoverIDs.CrouchStill * (crouch ? 1 : -1);
    10.      m_Animator.SetInteger(m_AnimatorBaseStateID, (int)m_CurrentCoverID);
    11.   }
    12.  
    It would be trivial to create a task that starts or stops a specific ability (just do RigidbodyCharacterController.TryStartAbility(ability, true)). You would have to use the Behavior Designer Object Drawers to be able to select an ability within the editor but that shouldn't be too hard to get going either.

    Thanks! Documentation and videos are definitely planned. I have been holding off on some of this just because I know that things are going to change before we hit version 1.0. However, this ability/animator system is working out extremely well and I don't plan on making any more dramatic changes to it after this update so you should be safe to start creating your own abilities.

    I wasn't planning on it but if it's small I don't mind adding it - what changes were you thinking?
     
  47. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Justin, I know you have said that you'll support AC in the near future, are you going to make your controller have a Adventure style point and click control as well?
     
  48. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Thanks for in-depth explanation. Workflow looks easy to expand.

    As for the camera; I've a custom camera solution I'd like to use with 3rd Person Controller. I was wondering if there are any changes that change custom camera usage with the controller.
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you have Behavior Designer you should already be able create a point and click now without any changes. Setup your character to be an AI Agent and then use Behavior Designer's seek task to move the character to the point that the player clicked. Adventure Creator integration is definitely coming soon, it won't be this update but I'll try to get it in the next update.

    I need to create a documentation page for how to use your own camera. You'll need to add a couple of SharedMethods to your camera script so the character knows which way to aim but other than that it should be ready to go. Take a look at the bottom of CameraController.cs for the shared methods that you'll need to implement - it's well commented so it shouldn't be easy to figure out what to do with your custom camera.
     
  50. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Can the soldiers be made to wander randomly instead of having an explicit patrol path assigned to them?
     
Thread Status:
Not open for further replies.