Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @opsive Actually, there were no errors during the building. It completed with no errors. The only errors I encounter are when I try to play the scene. Also, I can in fact see a capsule collider component on the root of the character along with all the other components.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    To reduce the noise in this thread can you send me an email/PM with your project so I can take a look?
     
  3. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thanks but don't block the 1.3 just for me I can wait or manage with only 1 generic
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    Most of the new 1.3 coding features are complete, there's just some cleanup and a lot of animations to do. I should be able to take a closer look at this next week - it may not even require something from 1.3 in which case I'll be able to put out a Behavior Designer update earlier.
     
  5. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Could you give me some guidance on setting up Setters and Getters for the inventory? I want to be able to tie it into ORK Framework easily. Specifically ammo.
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    The Inventory API is a good place to start. Is there anything in particular that you are looking for?
     
  7. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Edit: never mind. I figured it out. Can't do it in Start. What's a good delay to start it with?


    original message:

    Well this is what I've started with attached to the player and assigned the variables:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using ORKFramework;
    5. using ORKFramework.Behaviours;
    6. namespace Opsive.ThirdPersonController
    7. {
    8.     public class ORKInventoryHandler : MonoBehaviour {
    9.         [Tooltip("A list of items that will be picked up by the object")]
    10.         [SerializeField]
    11.         private List<Inventory.ItemAmount> m_ItemList;
    12.         public Inventory inventory;
    13.         // Exposed properties
    14.         public List<Inventory.ItemAmount> ItemList { get { return m_ItemList; } set { m_ItemList = value; } }
    15.         public int id;
    16.         // Use this for initialization
    17.         void Start () {
    18.        
    19.  
    20.             int iI = id;
    21.             foreach (Inventory.ItemAmount item in m_ItemList)
    22.             {
    23.                 inventory.PickupItem(item.ItemType.ID, item.Amount, false, false);
    24.                 // inventory.m_DefaultLoadout[iI] = item;
    25.                 iI++;
    26.             }
    27.         }
    28.    
    29.         // Update is called once per frame
    30.         void Update () {
    31.    
    32.         }
    33.     }
    34. }
    35.  
    But that give me this debug: "Unable to pickup item with id 797173046: has it been added to an item object?" I know it's attached to an item object and that item object is attached to the player's hand. What am I missing?
     
    Last edited: Apr 2, 2016
  8. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Next question is: how do I get the quantity currently in the inventory?
    I tried:
    Code (CSharp):
    1. inventory.GetItemCount(item.ItemType,false);
    but that returned:
    Code (CSharp):
    1.  
    2. ArgumentOutOfRangeException: Argument is out of range.
    3. Parameter name: index
    4. System.Collections.Generic.List`1[Opsive.ThirdPersonController.Inventory+ItemInstance].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    5. Opsive.ThirdPersonController.Inventory.GetItemCount (Opsive.ThirdPersonController.ItemBaseType itemBaseType, Boolean loadedCount) (at Assets/Third Person Controller/Scripts/Inventory/Inventory.cs:1011)
    6. Opsive.ThirdPersonController.ORKInventoryHandler+<StartMe>c__Iterator3A.MoveNext () (at Assets/Third Person Controller/Integrations/ORK/Integration/ORKInventoryHandler.cs:36)
    7.  
    8.  
    and I'm not sure how to fix that.

    Thanks!
     
    Last edited: Apr 2, 2016
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    You can subscribe to the OnInventoryInitialized event and that'll notify you after it's ready to go:

    Code (csharp):
    1.  
    2. EventHandler.RegisterEvent(m_GameObject, "OnInventoryInitialized", OnInventoryInitialized);
    3.  
    Are you getting the count before the inventory has been initialized? That line is pointing to an array within the SecondaryItemType array.
     
    drewradley likes this.
  10. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I set something up on the item monitor to get the quantities. It's a little crude, but it suits my needs just fine. Thanks for your help!
     
  11. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    320
    Hello everyone, i m using Opsive's TPC with ORK Framework, what i m trying to do is to have my animations ( new animations ). The part i m trying to figure out first is, how do i call a TPC ability on ORK ( i m using call function on ORK Events but i get the following error:
    Method not found (Opsive.ThirdPersonController.RigidbodyCharacterController): TryStartAbility
    UnityEngine.Debug:LogWarning(Object)
    ORKFramework.Reflection.CallMethod:CallStatic(String)
    ORKFramework.Events.Steps.CallFunctionStep:Execute(BaseEvent)
    ORKFramework.Events.GameEvent:ExecuteNextStep()
    ORKFramework.Events.BaseEvent:StepFinished(Int32)
    ORKFramework.Events.BaseEvent:Tick(Single)
    ORKFramework.Behaviours.EventInteraction:Update()

    Any idea ?
     
  12. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,487
    Looking forward to this update.
     
    opsive likes this.
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    For anybody else that hits this issue we have it solved in this post.
     
    SSL7 likes this.
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    I have the Start and Stop Ability tasks updated. I'll send you a PM with the new version. You can now specify an index if there are multiple abilities of the same type. This index corresponds to the 0th-based index value within the ability list. For example, lets say that I have the following:

    AbilityList.PNG

    Using the Start Ability task I would specify a Priority Index of 3 if I want to start the selected Generic ability (versus the one that is further down in the list):

    AbilityTask.PNG
     
    redjon29 likes this.
  15. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thank you very much!!! I'll test this soon:D
     
  16. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hi Justin I've tried the new scripts but I've errors when I run the game even with trees with no generic abilities. The character just stay in place. Do I have to set up something else before using it?

    NullReferenceException: Object reference not set to an instance of an object
    BehaviorDesigner.Runtime.Tasks.ThirdPersonController.StartAbility.OnUpdate () (at Assets/Behavior Designer/Third Party/Third Person Controller/Tasks/StartAbility.cs:32)
    BehaviorDesigner.Runtime.BehaviorManager.RunTask (BehaviorDesigner.Runtime.BehaviorTree behaviorTree, Int32 taskIndex, Int32 stackIndex, TaskStatus previousStatus)
    BehaviorDesigner.Runtime.BehaviorManager.Tick (BehaviorDesigner.Runtime.BehaviorTree behaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager.Tick ()
    BehaviorDesigner.Runtime.BehaviorManager.Update ()
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    Try downloading the tasks again from the same link - it should work this time :)
     
    redjon29 likes this.
  18. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thanks now it works you're the best:D:D
     
    opsive likes this.
  19. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Back in January, you helped me figure out how to set the weapon information from an outside script and I've discovered another problem: the icon doesn't update on the gui until I switch to that weapon, switch to another and then switch back.
    This is the code I've been using:
    Code (CSharp):
    1.     if (myShooter == null) {
    2.             myShooter = GetComponentInParent<ShootableWeapon> ();
    3.             if (myShooter != null) {
    4.                 myShooter.m_HitscanDamageAmount = damage;
    5.                 myShooter.m_ItemSprite = mySprite;
    6.                 myShooter.m_ClipSize = clipSize;
    7.             } else
    8.                 return;
    9.         }
    It seems to me that the item monitor sets the icon before it registers my changes to the shootable weapon script but I can't find a way to force it to reset the icon other than changing weapons multiple times.

    Any thoughts?

    Thanks!
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    My bet is that you need to execute the OnInventoryPrimaryItemChange callback since the ItemMonitor isn't checking for sprite changes. Take a look at the Inventory component for an example of this event being executed.
     
    drewradley likes this.
  21. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Perfect! Thanks!

    Side note: any news on that mesh collider/rigid body bug report?
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    No updates from Unity on that. I think that they'll update the Issue Tracker as soon as they make any progress. If anybody has any free Issue Tracker votes here is one that you can vote for.
     
  23. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    That's what I figured but thought there was a chance they emailed you for more info or something. I can't believe this isn't a bigger issue. It pretty much makes any physics based controller useless.
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    I wouldn't say completely useless but it does make certain situations tougher. You could do something similar to what we did with the warehouse and adventure scenes where we simplified the mesh collider. This would speed up your physics calculations anyway so it's not a bad thing to do.
     
  25. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I started replacing all my mesh colliders with primitive colliders, but that was taking way too long. I thought about simplifying them like you suggest, but again, time. I'd rather be making my game then editing assets I bought! So I just started a new project in Unity 4.7 and set my other one aside until it's fixed one way or the other.
     
  26. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    what's the best way to handle removing objects with bullet hole decals? I got a bunch of errors when my bullet riddle corpses get cleaned up.
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    What errors are you getting? The decal object should have the DecalRemover component which will place the object back in the ObjectPool after it has been disabled.
     
  28. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    584
    I get the same error to. Something about trying to reference an object thats been disabled.
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    What is the full error and do you have the steps for how to reproduce?
     
  30. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    584
    I can get it to you later tonight once I get to my computer. It doesnt happen all the time. I think it happens when my zombies are deactivated before the decal.
     
    opsive likes this.
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    That would be great if you could. I just deactivated an object which has a decal added to it and there were no errors. In the case of the zombie, you may not want decals added to it at all in which case you can ignore the zombie layer within the DecalManager
    DecalManager.PNG
     
    Last edited: Apr 9, 2016
    Gametyme likes this.
  32. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    For me, the easiest way to reproduce it is to destroy and object with bullet hole decals attached to it, then shoot. A lot. I "fixed" it by putting a null reference check before continuing. Once you get rid of one, another pops up. I had to add three checks to get the errors to go away.

    Here's the error:

    Code (CSharp):
    1. MissingReferenceException: The object of type 'MeshRenderer' has been destroyed but you are still trying to access it.
    2. Your script should either check if it is null or you should not destroy the object.
    3. Opsive.ThirdPersonController.DecalManager.Fade (UnityEngine.Renderer decal) (at Assets/Third Person Controller/Scripts/Game/DecalManager.cs:194)
    4. Opsive.ThirdPersonController.DecalManager.Update () (at Assets/Third Person Controller/Scripts/Game/DecalManager.cs:66)
     
  33. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    584
    That looks familar.
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    A null check would prevent the error but I'd like to figure out the source. Here's what I tried:

    1. Opened the shooter scene
    2. Made Doug invincible
    3. Held down the fire button and continuously shot at the barrel. When the barrel exploded I didn't let go of the shoot button and the barrel respawned three or four times before I was out of ammo. During that time I didn't get any errors and an object with a decal would have been destroyed.
     
  35. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    584
    I never seen this before 5.4 or maybe 5.3.4. Also, Im still 2 versions behind.
     
  36. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I just put a cube in the scene with a 15 second self destruct and shot it. When the timer ran out, I go the error. This is in Unity 4.7. Perhaps it's a unity issue fixed in later versions.
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    I just attached the following component to a cube:

    Code (csharp):
    1.  
    2. public class DeactivateObject : MonoBehaviour {
    3.   private void Start()
    4.   {
    5.   Invoke("Deactivate", 10);
    6.   }
    7.  
    8.   private void Deactivate()
    9.   {
    10.   gameObject.SetActive(false);
    11.   }
    12. }
    13.  
    I was able to shoot 63 bullets before the cube deactivated. After I do that there are no errors. Do your decals have the DecalRemover component on them? I do not think that this is related to Unity as the callbacks haven't changed.
     
  38. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Yes they do.
     
  39. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    Has there been any changes regarding issues with this error on the network demo?:
    I do in fact have the ENABLE_MULTIPLAYER symbol in the player settings. I even removed it and pasted it in manually again just to be sure, but I still am seeing the error. It is the unmodified network demo scene I'm trying to test.

    Sorry if this has already been addressed. I looked back through this thread but the things listed before don't seem to help. I'm using Unity 5.3.4. And yes, I have seen this. I've done everything it says, but nothing seems to help.
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    Can you send me a PM with a repro scene? This one really sounds like it should be able to reproduce but I'm just not able to.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    The only time that I've seen this happen is when the web player build target is selected. Make sure you've selected the windows or Mac OS platform
     
  42. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @opsive Yeah, I have it selected to do a Windows build. And I'm just attempting to run it in the editor. Haven't even tried to do a build yet.
     
  43. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @opsive I guess it should be noted that I am able to run the scene and move the character around and shoot. But I do get that error as well as some warnings. This is everything I get:
    And this is the vanilla network demo scene. I haven't changed anything in the scene.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    It sounds like this is correct, but even though you aren't doing a build you still need Windows selected for networking to work.

    I just looked at your original post again. It doesn't look like you have the source code imported. This is definitely needed for networking to work.
     
  45. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @opsive Ah, that fixed it! Now I feel dumb. :p

    Thanks a lot! :)
     
    opsive likes this.
  46. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hello everyone I've tried to play some hit animations when a character is damaged. For that I've replaced the animations in the additive layer on the animator and added the damage visualisation ability. And I've changed the mask to "none" and blending to "Overrride". With this setup the character stop walking, attacking ... and plays a hit animation when I shoot at him
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    If you don't want to use the Additive layer for Damage Visualization I recommend that you place it in the Upper Body layer similar to the other abilities. You'll need to change the DamageVisualization.GetDestinationState method to use this new layer:

    Code (csharp):
    1.  
    2.   public override string GetDestinationState(int layer)
    3.   {
    4.   // Only the upper body layer can play a damage animation.
    5.   if (m_DamageType == DamageType.None || layer != m_AnimatorMonitor.GetUpperBodyLayerIndex()) {
    6.   return string.Empty;
    7.   }
    8.  
     
    redjon29 likes this.
  48. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thank you, I don't understand what you mean by not use the additive layer. If I use only the upper layer the character will keep running if I shoot at him This way he stops and plays a hurt animation.I think it brings more life in the game because character reacts to damage. Here you can see it on a video sorry for the bad quality I was on my laptop and cell phone
     
  49. drakekaz

    drakekaz

    Joined:
    Jan 16, 2014
    Posts:
    42
    Hello there, love the plugin. Just a quick question. I am having some issues replacing the animations for the animator. My custom weapon aim states freeze when I use them and when I replace my the movement animations my character leg drags behind it. Is there something I am missing? Thanks for the great tool!
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,844
    It sounds like you should continue to use the Additive layer then. You don't want to set the layer as override - this will cause the animation to consume the entire character which is something that you don't want. Instead take a look at the shooter controller for an example of the Additive layer - you can specify a mask but the import part is to use Additive blend type instead of the Override blend type
     
    redjon29 likes this.
Thread Status:
Not open for further replies.
unityunity