Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    Well I figured out you need to have the Zoom camera state in the list too. Top Down still doesn't work right, the camera ends up somewhere in the characters hips and there are 2 exceptions, each the same message:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Opsive.ThirdPersonController.CameraMonitor.UpdateTargetLookRay (Boolean updateInput)
    3. Opsive.ThirdPersonController.CameraMonitor.LateUpdate ()
    4.  
    and the character still isn't controllable by point click.

    A tutorial video how to set up UMA with different controls and cams would be nice.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Instead of commenting the line out have you tried populating the Base field? This will allow the item to be created successfully. Here's what that component looks like in the sample scene:

    ItemBuilder.PNG


    If you import the source and repost the error with line numbers I'll have a better guess, but did you attach the NavMeshAgent? This is necessary for the PointClick Movement Type.
     
  3. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    Alright, I imported the source code and added the pistol, that works now. I did add a navmesh agent. Here's the exception with imported source code:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Opsive.ThirdPersonController.CameraMonitor.UpdateTargetLookRay (Boolean updateInput) (at Assets/Third Person Controller/Scripts/Camera/CameraMonitor.cs:153)
    3. Opsive.ThirdPersonController.CameraMonitor.LateUpdate () (at Assets/Third Person Controller/Scripts/Camera/CameraMonitor.cs:132)
    and this is the exeption when i click somewhere:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Opsive.ThirdPersonController.PointClickControllerHandler.FixedUpdate () (at Assets/Third Person Controller/Scripts/Character/PointClickControllerHandler.cs:54)
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Let's start with the first error because when there has been one error chances are the rest of the execution isn't going to work properly.

    There are a few different objects which could be null - can you set a breakpoint/use Debug.Logs to determine which object is null? It'll either be m_TargetLookRay, m_CharacterTrasnform, or m_CharacterController(.CapsuleCollider). From there I should be able to get a better idea of what went wrong.

    What actually may be easier is if you just send me your project to support@opsive.com - this way I'll be able to take a direct look at it and see what the issue is.
     
  5. Deleted User

    Deleted User

    Guest

    I know I asked you when the next big update for TPC and UFPS will get released. I just want to start a new project in the near future and I am considering using TPC 2.0 when it gets released. Would you say you could release it within 3-4 months? I mean your competition recently released Third Person Controller - Shooter Template and I dont know which Third Person Controller I should use now. I prefer TPC with Behavior Design but it doesnt feel AAA enough for me right now. And having a First Person option with UFPS 2.0 (linked with TPC 2.0) would be really nice.
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    3-4 months is probably too aggressive. Things are looking good for this year though.

    We are taking our time with version 2 to make sure it is done right - we'll start to post more and more about it the closer we get. There are some features included which haven't been mentioned yet but I'm really excited about and should make it extremely flexible. All in due time :)
     
    Last edited: Apr 29, 2017
    TeagansDad and Deleted User like this.
  7. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Thank you so much for your help. I've now nearly completely implemented the character controller!

    There are just a few remaining issues.

    I notice if I switch to the Sniper Rifle, and then to any other ranged weapon, if I aim, I'll see the scope.

    IE: If I have the assault rifle, and aim, no scope, just fine. Same with rocket launcher, but if I switch to the sniper rifle and aim, and get the scope view, as expected, whenever I switch back to the other weapons that scope view persists when aiming.

    Any thoughts?

    Also I've tried opening the source code page from the documentation but none of the links in the PDF work: "The full source code can be downloaded from this page." - I have tried in a few viewers but although the link is underlined, its not clickable. Could you send me that link, either here or in PM?

    Thank you!
     
  8. ocimpean

    ocimpean

    Joined:
    Aug 10, 2013
    Posts:
    128
    Are there any tutorial videos regarding integrating Adventure Creator and Dialog System with Third Person Controller?
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    If it helps, there are separate Pixel Crushers tutorials for integrating the Dialogue System with Third Person Controller and with Adventure Creator.
     
    Weblox and opsive like this.
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Awesome!

    Here's what I tried:

    - Add the SniperRifle ItemType to the default loadout within the shooter scene
    - Start the game, switch to the Assault Rifle
    - Aim with the Assault Rifle
    - Switch weapons to the Sniper
    - Aim with the Sniper
    - Switch weapons to the Assault Rifle
    - Aim with the Assault Rifle

    At this point the scope was not in view and the Assault Rifle was aiming like normal. Should these steps reproduce what you are seeing?

    Here's that link.
     
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    In addition to Tony's message, the Third Person Controller / Adventure Creator documentation is here.
     
    TonyLi likes this.
  12. Urishizu

    Urishizu

    Joined:
    Sep 24, 2016
    Posts:
    158
    Quick question. My game is an adventure game (think Resident Evil) and I want to allow the character to aim UP, DOWN or AHEAD. Up is basically just raising their arms a bit into the air, down is lowering their arms to face the ground and ahead is just facing straight ahead.

    I'm in RigidbodyCharacterController inside Move and the Rotation functions. I'm able to track the player input to know when they press up or down, but how do I rotate ONLY their upper body (which in turn has the arms attached and gun) to raise or lower? I just want to rotate it a bit upwards or downwards (it doesn't need to accurately aim at anything). But when I mess with eulerRotation and such, it rotates the entire character model.

    I ended up doing a workaround by modifying the localRotation of the abdomenLower object, which looks really good on my end. But I bet there's a less hackish way to do this directly within TPC, so I'm interested to hear what it may be.
     
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Glad you got it working!

    I would do it in one of two ways:

    - Use IK to rotate the upper body to point towards the target. The CharacterIK component will use Unity's IK implementation for this, though I haven't tried it with Photon.
    - Create an ability which plays an animation that rotates just the upper body based on the pitch angle to the target.
     
    Urishizu likes this.
  14. ocimpean

    ocimpean

    Joined:
    Aug 10, 2013
    Posts:
    128
    @tony Li @opsive: thank you for the links. I got Dialogue System while back for a text only project and I would like to try to see how is working in a more complex environment now that I bought the Third person controller.
     
    opsive and TonyLi like this.
  15. Urishizu

    Urishizu

    Joined:
    Sep 24, 2016
    Posts:
    158
    Hi,

    Is there a built in way to have an animation fire when taking damage? I didn't see anything just browsing through a lot of the standard scripts included on the TPC character.

    Thanks!
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes - take a look at the Damage Visualization ability. This ability has been added to the character within the shooter scene. This ability uses the additive layer to play a backwards/forwards animation when the character has been hit.
     
  17. Fraust

    Fraust

    Joined:
    Jul 2, 2012
    Posts:
    16
    Ok, I yield... it's late but I yield. What am I missing that is causing my weapon to go through my level? Is that just how it is? I tried the clean scene from my project, blank project, and the opsive website demo area. All have this problem where i can shoot through the wall if I'm standing against it. Maybe I'm just tired... it's 3 AM right now... I seem to remember this worked in the past... but it's late... need sleep lol. Capture.PNG
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    The fire point on the rifle is within the geometry so when a raycast is done from that position it's not going to hit the object directly in front of the character. You could either increase the radius of the collider or move the fire point so it is closer to the hands of the character.
     
  19. Deleted User

    Deleted User

    Guest

    Am I right that TPC 2 will not be that huge of an update compared to UFPS 2? So would you recommend me using TPC today (of course you would because you guys are the creator of that... thats not what I meant if you guys understand me)? I would like to have something like a roadmap what new features will be implemented etc if possible.
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    We haven't gotten far enough to determine a migration strategy yet but we'll try to make it as easy as it can be. Our recommendation will probably be to stick with version 1 if you're far along with your game and you don't need the first/third person perspective change.

    We are taking the best parts of UFPS and TPC so there are some parts that are more similar to UFPS while some parts are more similar to TPC. Right now I can say the character locomotion aspect is similar to UFPS, while the ability system is similar to TPC (though the API has changed). We will continue to support version 1 for some time after version 2 release just to make the transition as smooth as possible. Again, we'll have more details on this when we get closer to release later this year.

    We don't have a public roadmap for version 2 but when we get closer we'll start to highlight the major new features and also talk about how it all fits together in the documentation.
     
    Deleted User likes this.
  21. Fraust

    Fraust

    Joined:
    Jul 2, 2012
    Posts:
    16
    Ok, phew, I'm not losing my mind then. Sorry, with so many switches in the controller it's easy to think I overlooked something.

    Just a suggestion, but perhaps an ability for hugging the wall would be good. If too close to a facing wall then hold the gun up to the sky like you see a lot of times in movies, etc. Moving the fire point doesn't change the actual fire direction though (in case I was holding the gun upwards), just the origin right?

    Does changing the character collider size affect hit detection for taking damage?

    Hmm... maybe I could hide it with a cover ability...
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for the suggestion - I like it and have written it down!

    Correct

    It does. I bet you could play with the LayerMasks though so you have a set of 'inner' colliders which are used for hit detection while the main collider is used for collision detection. This would be similar to headshots:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=128
     
  23. Deleted User

    Deleted User

    Guest

    Have a look at Third Person Controller - Shooter Template and play the Shooter Demo. I hope TPC 2 (and UFPS 2) can compete with this, better beat it. What I personally miss in that other asset is:

    *A weapon wheel (mouse wheel or pressing a number key) to quickly switch weapons.
    *Shooting from the hip without needing to aim (look at GTA 5).
    *Rolling to left, right and behind while aiming.
    *Leaning left and right and peek above.


    Some pages ago on this thread I also wrote this for TPC 2 + UFPS 2:
    I would like to add the following:

    • Collision Detection - when near a wall, the weapon should not get stuck but instead raised up or down
    • Switching sides - so the character is not always on the left but can also be on the right side (see Red Dead Redemption for example)
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Make sure you watch this thread for when we start to run the betas. We've ran the first alpha test to gather feedback and so far it has already helped a ton. When we reach the beta stage the feature set will be more concrete and we'll have a more accurate estimate on the release date as well as what will be included. We are not going to release until we are 110% happy with it.
     
    TeagansDad and Deleted User like this.
  25. Adam-Sowinski

    Adam-Sowinski

    Joined:
    Oct 25, 2013
    Posts:
    129
    Are there any plans to integrate with CineMachine and Timeline regarding how cameras work in Third Person Controller? I've played around with Unity 2017.1 beta and it seems to be a very powerful system. At the moment TPC uses camera states - these could be integrated with Timeline to allow smooth transitions and more design time tweaking.
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    This was the first time that I've seen CineMachine - that looks really useful. Timeline sounds like it is going to be a popular request - you're already the second one to mention it and it's not even out of beta yet :)

    To answer your question, yes, though it may have to wait until version 2. In version 2 the camera view types are more dynamic in that they are separate objects instead of enums. This allows you to do some really neat things such as transition between two different view types:

    https://twitter.com/Opsive/status/851887635853443072

    Originally I said that we don't plan on doing any more v1 integrations but since timeline will be a core Unity feature I'll try to add that in if it doesn't require restructuring the existing view types.
     
    Adam-Sowinski likes this.
  27. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Hi, yesterday i bought the asset and i have some question:

    How can i swap between specific weapon that i have in TPC inventory if a specific condition is verify like (without using Q or E):

    "if (equipmentSlot[1].name == "Pistol") {
    //the function here like
    Inventory.SetCurrentWeapon(equipmentType[1].name);
    }"

    Where i can find the method called everytime that i shoot, i need it to decrease my ammo in other item that is external to TPC to save the amount of bullet in database.

    How can i set available bullet at runtime for the weapon that i use at moment if i have my amount memorized in other item that i can already save in a database?

    I know is a lot of question :)

    Thanks

    Edit : i make a try to network scene and the pistol damage doesn't work
     
    Last edited: May 13, 2017
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for your purchase!

    This is actually built in - take a look at m_CanEquipSpecifiedItems within InventoryHandler.cs. The button name is set within theConstants file.

    ShootableWeapon.Used is called when the item is about to be used. You can place your ammo change within DoFire.

    You can use Inventory.SetItemCount.

    Make sure you've followed the steps on this page for setting it up. From there check the damage layer mask on the pistol - the target's layer has to be included in this mask.
     
  29. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    For m_CanEquipSpecifiedItems i don't need to set another button i need that in a specific condition i can select a specific weapon by name and set as primary.
    Can I try with InventoryHandler.TryEquipItem; ?



    Where i can find the pistol with the script to change the layer?

    Edit: I found Pistol and i notice that are not projectile specified, so you suggest me to create a bullet or use hitscan? which is the layer to damage enemy (i notice that enemy layer is already selected)
     
    Last edited: May 13, 2017
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes - TryEquipItem is correct.

    It's under the Shootable Weapon's Hitscan Collision Options.
     
  31. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Is i see it but which layer i must select to hit player? player and enemy is already selected and player child layer are Ignore RayCast that is already selected
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Are you working with the network demo scene or your own scene? In the network demo scene the spawned characters have a layer of Player, and in the Hitscan Impact Layer field includes the Player layer. I just tried it again and when I fired the weapon the networked character took damage.
     
  33. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Yeah i'm import the package delete the script and import package with source code , build with the Network Scene, open one windows for client and one for server and pistol don't decrease health , only rocket Launcher do damage.
    I try this process three times with three fresh project and still no works.
    Now i'm at work and i can try the fourth times :) , i cannot understand what i'm doing wrong because i don't modify anything,

    Thanks!
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    When I just tested the scene earlier I was using my local branch instead of the Asset Store version. When I tried the Asset Store version I hit the same thing that you did.

    I would send you a PM with the latest code but parts of my project are a mess right now so you probably wouldn't want it :) We are working on an update that'll go out within a few days and with that you'll definitely be able to cause damage to the networked player.
     
  35. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    I can wait new release if this bug is fixed... i wait the new release to implements my custom inventory manager.

    Thanks!
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    This next release will contain the network fix, but you should be able to start on your custom inventory manager now - that aspect won't change in this next release :)
     
  37. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Ok i would wait to check if the script that manage inventory item change...if is not the case yes I can start with...
     
  38. Deleted User

    Deleted User

    Guest

    TPC is Unet ready. Now do I need to setup complicated stuff to make a multiplayer game or is it a core element which doesn't need manual opt-in and settings here and there etc.? I would like to make a small project with multiplayer, thats why I ask.
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    From the controller side of things you'll just need to follow these steps:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=76

    It is independent of things such as a lobby or matchmaking.
     
    Deleted User likes this.
  40. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Hi why my crosshair for pistol doesn't shown? all the sprite are setted.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
  42. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I'm not following - can you add more details to your question?
     
  44. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    I have my canvas with my UI windows and when press the x button image for close the windows, the player shoot, how can i do to avoid this? i must assign a particular layer to the UI or what?
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
  46. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Make sure you aren't enabling input again until after the UI is hidden. For some background, the aiming is triggered within ItemHandler.Update. At the top of this method is a check to see if input should be allowed - if it isn't then the item will never get a chance to aim.
     
  48. Michealunity

    Michealunity

    Joined:
    Mar 15, 2015
    Posts:
    65
    Thanks!
    I did it.
    TryEquipItem index refer to default loadout index or what?
    I need to understand how set index parameter to switch weapon, i make some quick test today and my manager start to works.

    Thanks
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    It refers to the order that the item was added to the inventory. You can specify this order under the "Item Order" dropdown of the inventory.

    order.PNG
     
  50. Cartoon-Mania

    Cartoon-Mania

    Joined:
    Mar 23, 2015
    Posts:
    320
    Are you planning to add a crafting system?
     
Thread Status:
Not open for further replies.