Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Check the collider on your bow - if you reduce the size it should prevent any collision with the character.
     
  2. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Will do thanks agian.
     
  3. mrdl2010

    mrdl2010

    Joined:
    Jun 1, 2016
    Posts:
    23
    In my old character script, there are some lines of codes to prevent rewired from getaxis outside of game window. Now since I move to third person controller, can I set up it somewhere or I need to implement myself?
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The Rewired input doesn't contain any logic for detecting if GetAxis is outside of the game window - you could implement this within the RewiredInput.GetAxis method.
     
  5. RicheyMB

    RicheyMB

    Joined:
    Jul 20, 2009
    Posts:
    111
    I am looking at a project where a requirement is to swtich between a first and third person perspective. Would this be possible with this controller. Especially interested in the UFPS integration timeline. Could development start with this controller and first person be added when integration is complete?
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    We've had a couple of users add a first person view, though it won't officially be supported until the UFPS integration.



    We've started on the integration and for that we're basically starting with a blank project and adding the best parts from both the Third Person Controller and UFPS. I don't have an estimate but it'll be sometime in 2017 when it's released. Since we're still at the beginning on this project I don't have an idea of what it'll take to update to it - but I'm going to try to make it as painless as possible which will hopefully mean having some editor scripts which will do the update for you. When we get to this stage we'll make sure to get a lot of beta testers to ensure everything is as smooth as possible.
     
    CupariKun likes this.
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I'm setting up a horse for my game and I don't see a specific video of instructions on all the details. I'm wondering about a couple of things. First, what should I do for the Item Transforms and Foot Transforms? Second, how can you start a scene with the player character already mounted on the horse? More specifically, is there a way to simply call a function to instantly mount or dismount a character instead of having to make the player perform these actions? I want to start a scene with the character already on the horse.
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    A horse doesn't need any item transforms because your horse isn't going to be using any items (I'm assuming..) The foot transform specifies the location of the foot bones on your horse - this is where the footstep trigger and audio source will be attached to.

    You can force start an ability with TryStartAbility but in the case of the ride ability it'll start by playing the mounting animation. You'll need to modify this ability so it calls the Mounted function immediately after it has started. I haven't tested this though so it may take some more setup to get going, but that should get you started.
     
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    This sounds a bit tricky. I'll give it a try tonight.
     
  10. RicheyMB

    RicheyMB

    Joined:
    Jul 20, 2009
    Posts:
    111
    Thanks for the prompt reply :)
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I'm working on horse riding again, but I can't seem to get my own setup to work. I've got my main character in a starting scene and the horse in a scene that loads async. Basically, the starting scene has all the objects that will always be in the game no matter what scene I'm in. When I press Start from the starting scene then it activates the first loaded scene that has the horse in it. The problem I'm seeing is that the camera is focused on the horse, but movement is controlling the player character. I can't figure out how the camera is not focused on the player character since I haven't mounted the horse yet.

    [EDIT]
    I figured it out. I was activating the new scene before the player character was activated and so the horse was probably grabbing the camera before the player character could.
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Make sure you've disabled input on the horse using the OnAllowGameplayInput event:

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

    And you can set the character that the camera is focused on by setting the CameraController.Character property.
     
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I've changed the way I want to do this so I'm no longer starting the scene with the character mounted. So, I just want to have the player mount the usual way. Do I still need to disable input for the horse? I have it now where the player character moves around and has camera focused on her and the horse is standing ready. However, I'm never able to actually mount the horse. I've been looking closely at Blitz in the Clean Scene, but I can't find any differences. I have the same mount points, the same Colliders, I've added the Rideable component, the player character has the Ride ability, etc. Yet, I can walk all around the horse and never get to a point where I can mount it. Is there something you can think of that I might have missed?

    [EDIT]
    For sanity sake I copy and pasted Blitz into my scene and I can't mount him either. So it seems the issue may be with my player character. Hopefully that helps to narrow down suggestions on what to look for.

    [EDIT 2]
    Sanity check #2. I copied Dom Shooter from clean scene along with the Main Camera, Game, and EventSystem into another scene. In this scenario, Dom is not able to mount Blitz. There must be some code somewhere in the clean scene that makes this possible that isn't in my test scene.

    [EDIT 3]
    Scratch that last test. I didn't have the GUI in the test scene so it wasn't showing the Press F to Mount, but when I pressed F then Dom mounted Blitz.

    [EDIT 4]
    Making some progress. My Animator didn't have the Ride states on it so now I am able to mount Blitz in my test scene, but my horse is still a no go. One thing I noticed though is that the character mounts the horse not quite right. She steps about half a foot too low and also sits in the horse beneath the saddle about the same distance. How can that be adjusted?
     
    Last edited: Sep 24, 2016
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    @magique - The RideableObject on Blitz will disable the input at the start so you don't need to manually. The mount height is determined by the animation, so you'll need a mounting animation that fits the height of your character.
     
  15. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I have to have a custom mount animation? I totally did not anticipate that. What about the other issue of not being able to mount my own horse? I can mount Blitz, but not another horse that appears to be set up almost identical to Blitz.
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Mounting uses root motion so that's why it requires an animation for your characters height. In a future version I can look at not requiring root motion for the mount but the movements won't be as accurate as they would be with root motion.

    If you can't mount another horse you should first check the layer on that horse. It has to match the layer specified in the Ride ability. Besides that you'll want to ensure the collider is setup similarly to Blitz so when a raycast is being performed to determine if the character can mount that raycast will hit your horse.
     
  17. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Already did all that.
     
  18. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    617
    Hey, I updated to 1.3.3.1 and updated cf now the grenade button doesn't work. Although, he now throws a grenade when I press the shoot button.
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I don't have any more ideas off of the top of my head so what you can do is place a breakpoint within Ride.CanStartAbility in order to debug which condition is failing. This should then point you to what part of your horse you need to adjust.

    There are three conditions:
    - The character is grounded
    - The raycast hits a RideableObject
    - The angle between the character and RideableObject is less than the max mount angle.

    Take a look at the first item in the update guide: http://opsive.com/forum/index.php/topic,3007.0.html
     
  20. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I ended up simply taking Blitz and ripping out the underlying horse and copying in the horse from mine. Surprisingly this works. Yet I still see no difference in any other part of it. I guess it'll remain a mystery for now, but at least I got it to work.
     
  21. Oryor

    Oryor

    Joined:
    Sep 21, 2016
    Posts:
    8
    Hello, i recently purchased this character pack and am trying to set up a networkable character, i tried following your guide but i did not see the option to add multiplayer symbol, and when i try and run the project i get a few errors:
    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.NetworkMonitor.Update ()
    -
    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.ControllerHandler.FixedUpdate ()
    -
    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.NetworkMonitor.SharedMethod_TargetLookPosition ()
    Opsive.ThirdPersonController.SharedMethod`1[UnityEngine.Vector3].Invoke ()
    Opsive.ThirdPersonController.CharacterIK.LookAtTarget ()
    Opsive.ThirdPersonController.CharacterIK.OnAnimatorIK (Int32 layerIndex)
    what am i missing?
    thanks in advance
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Make sure you've using the latest version and performed each step in this guide. I'd perform this in a fresh project just to get the hang of it as well. Also, the web player doesn't support UNET so ensure that you're on a different platform.
     
  23. Oryor

    Oryor

    Joined:
    Sep 21, 2016
    Posts:
    8
    I am on a fresh project and am just running it in unity, i have the most up to date versions, i cant find where to add the ENABLE_MULTIPLAYER tag tho as the player does not have the option as the guide would say it does.
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Did you import the source? I just looked at your stack trace again and don't see line numbers so I bet that is one cause.
     
    Last edited: Sep 26, 2016
  25. ElGuapo

    ElGuapo

    Joined:
    Sep 27, 2016
    Posts:
    9
    Does the clean scene demo bind up for anyone else when using dual pistols and the platformer mode (no root animations)? I was trying to shoot the pistols while moving in this mode (both guns alternating), but the guns refuse to fire nearly every time.
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I just tried it out and was able to reproduce what you're seeing. You'll want to change the Item Use Rotation Threshold on the RigidbodyCharacterController from 1 to 180. That should then allow the platformer character to always fire.
     
  27. ElGuapo

    ElGuapo

    Joined:
    Sep 27, 2016
    Posts:
    9
    Okay, thanks very much.
     
  28. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Hi Justin,

    my game's is using the topdown view and I'm trying to tweak to the camera movement a bit like Xenoworks is doing.

    First I like how you move the cam up when there's by example a wall blocking the view. My problem is more with the rotation. Sometimes you end up where the cam is shifted 180 degrees and then the controls suddenly appear as being reversed and it's really confusing.

    I can always stop the cam rotation ( just keep the up and down movement) but would prefer a way to re-orient the controls where UP is always UP !!!

    I'm a bit lost at this point....

    thx
    Chris
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Have you tried restricting the pitch angle to prevent it from going upside down? If that's not it, are you able to reproduce it in the clean scene with the top down character so I can see what it's doing?
     
  30. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Yes I adjusted the pitch angle. I'll try to replicate in clean scene tonight.

    In my scene, it's happening by example if you enter a shack with a roof...or just standing under a door arc ( if there's a Default layer mesh over the door.
     
  31. ElGuapo

    ElGuapo

    Joined:
    Sep 27, 2016
    Posts:
    9
    I'm a new user and having this same problem. I'm following the guide, but the button described in the guide ("Add Multiplayer Symbol") is not showing up in my Rigidbody Character Controller (script) component. Maybe this is an error with the current version?
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Here's a quick video showing the setup using the latest version: https://www.dropbox.com/s/j8wugueubt0noxp/network.avi?dl=0.
     
  33. ElGuapo

    ElGuapo

    Joined:
    Sep 27, 2016
    Posts:
    9
    Okay, I watched the video, but it mostly just confused me with the first part. I was totally lost until I found that I needed to follow this step: http://opsive.com/assets/ThirdPersonController/documentation.php?id=50

    Yes, I am just getting started. Thanks for your help.

    Edit: Cleaned up a whole bunch of mess and replaced it with the solution.
     
    Last edited: Sep 29, 2016
  34. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I'm trying to understand the intended workflow for using the Health component on objects such as barrels, crates, etc. It's very easy to attach the health component to a barrel and have it get destroyed after striking it, but if it takes multiple strikes to destroy it there is no visual/audio feedback such as hit effect/hit sound. So I'm thinking I need to inherit from Health and override the virtual Damage method. I could provide additional fields for specifying hit sounds and hit effects and they would play on being damaged. Is this the correct way to go about this or is there something else I am missing that might make this even easier?
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    You could subclass, or you could subscribe to the damage event: http://opsive.com/assets/ThirdPersonController/documentation.php?id=117
     
  36. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
  37. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Hmm. I'm not quite getting it to work. I'm now getting impact sounds and impact effect even without changing anything so I'm not sure what I did to get that going, but when I make a Damaged script and attached to the barrel, it is not getting the handler called. The documentation says to change the Hitscan Damage Event field, but a melee weapon doesn't have this. However, it does have the Impact Options Damage Event so I made that equal to Damaged. But I don't see any log output to tell me that the event is getting received.
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The MeleeWeapon has the DamageEvent which is similar to the HitscanDamageEvent on the ShootableWeapon. The rest is the same between melee and shootable items.

    The callback did change a bit in the most recent version so if you are running an older version take a look at the documentation within the Third Person Controller directory for the syntax.
     
  39. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    That was it. I am using an older version and the parameters did change. It is working now.
     
  40. barikinil

    barikinil

    Joined:
    Apr 15, 2015
    Posts:
    11
    Hello,
    Could you help me about creating a jumping ability pls.
    I am trying to make ability like jump forward over a gap or hole to the forward roof with matchtarget to the specific location. Character should jump to ahead roof specific location.
    I look Vault, Jump, and Balance vs ability. But there is problem with stages.
    1. Find gap, hole ahead the character, Find ahead roof settle point within distance. ( I did this.)
    2. Jumping with 3 stages = start, mid, fall N settle. Not 2 stage (start+midAir)+ fall ability
    3. Jump through to settle point with natural movement. I tried m_Rigidbody.velocity but I did something wrong. didnt work. addforce with impulse maybe applied. I dont know.
    4. I guess i have to use MatchTarget (for foot) for fall N settle stage to settle ahead roof
    I tried to visualize like below. jump.png
    I will add some code this afternoon that i tried.
    If you would share idea with me, I would be appriciated.
    Regards.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Once you've found the target landing point, you could control the jump movement directly by assigning the RigidbodyCharacterController velocity. This will then allow you to move precisely where you want to move - you shouldn't need to use match targets. You would model the jump movement off of a parabolic curve so the jump looks natural the entire duration.
     
  42. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    I have a very unusual situation that maybe you can help point me to a solution for. I have a game object in my scene that has a box collider so the player can't move past it. However, if the player touches the object with fire then the object burns and I disable the object, including its collider. So, what happens is that I move the player up to the object with a torch in hand and as the torch makes contact, the player is also prevented from moving forward due to the box collider. The strange thing is that after the object burns and I disable to object with the collider, I am still unable to move forward. If I back up a little bit and then move forward again then I can bypass the block. In some cases, I've actually seen it where if I back up then I cannot move forward at all. I keep backing up and turn and try to go forward and it is like there is an invisible barrier there preventing forward movement. I am using Unity 5.3.6p2 and TPC version 1.3.2.
     
  43. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    @magique Maybe your original object is set to Static...
     
  44. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,629
    Possibly a navmesh issue?
     
    99thmonkey likes this.
  45. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Either way has no affect.
     
  46. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    There is no navigation in the scene currently.
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for helping @RedHawk and @hopeful -

    When the Rigidbody Character Controller collides with an object that object gets added to a collision set to prevent the character from being able to continuously run into the wall. When you disable the object it never gets removed from that collision set because OnCollisionExit doesn't get called. The easiest way to prevent this from happening is to add your object to the VisualEffect layer, this will prevent the object from being added to that set.
     
  48. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Thanks, Justin, I will give this a try.
     
  49. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    OK, that didn't work. With the object set to VisualEffect, there is no collision now and the player can walk right through the object. It also ignores the fire collision as well. I have the Fire set to IgnoreRayCast and I've verified that IgnoreRaycast can collide with VisualEffect layer in the Physics matrix.

    I also have another issue I'm working on. I have a Torch item set as PrimaryItem type and the torch item has the StaticItem script attached. However, even though I have it default to being equipped, it is turned off when I run the game. For testing I've been pausing the game and turning it on, but I can't figure out why it won't equip it to begin with.

    [EDIT]
    For the collider issue it turns out that I wasn't disabling my object with the collider as soon as I thought and it was in fact still active. After waiting a little bit, it disabled and I could pass. Not sure why the other issue was occurring with the forward movement not being allowed at all, but it seems to have disappeared for the time being.
     
    Last edited: Oct 4, 2016
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That makes sense now that you say it. I'll think of a way to handle this use case and get back to you when I have a solution.

    If you can reproduce it in a demo scene with an existing ItemType I should have a better idea at what is causing the item to be disabled. You should also update to 1.3.3 as there were lots of fixes in this version and it was a good polish release.
     
Thread Status:
Not open for further replies.