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

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    Now I remember why I don't use breakpoint debugging in Unity. It never seems to work. I just get the following:

    upload_2018-4-5_6-23-17.png
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    Oooh, I think I know the problem. I just tried a test again with the Maximize on Play button disabled and the problem no longer occurs with the Jump. This reminded me of an issue that Vegetation Studio had with a Unity quirk where some initialization code would not get executed if in Maximize On Play was set. I can't remember how he solved the issue on his end though. I will try to find the discussion about this or I will text him to see if he can shed any light on it.
     
  3. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    Ok, so I chatted with Lennart from VS and he said "I think it was a bug where no sceneview existed". He was relying on that sceneview to do some code and it would fail because in that Maximize mode it wouldn't exist. I'm not sure if your code does anything similar. It's very odd though that this problem just vanishes when not in the Maximize mode. But it also fails on a console build.
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    There isn't any scene view code within TPC. Can you reproduce it within the demo scene? I just tried it and wasn't able to reproduce it with the game view maximized.
     
  5. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I'm going to try that now. Perhaps this is a UMA 2 issue.
     
  6. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    In the Adventure scene with Naomi it works fine either way, but with the UMA 2 character it has the same issue and is fixed by not being in Maximize mode. I suppose this must be a UMA 2 issue somehow, but it makes no sense to me.
     
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I'm checking with UMA 2 author to see if they might be relying on that sceneview mechanism.
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I'm trying to debug my issue further on the TPC side because it seems the UMA side was a dead end. I'm trying to figure out at what point the Ability is refusing to start and I am seeing something that makes no sense to me. In RigidbodyCharacterController there is a function as follows:

    public bool TryStartAbility(Ability ability, bool ignorePriority)

    I put some debug code in there to print out the name of the ability as in Debug.Log("TryStartAbility " + ability.name), but I'm seeing this message spammed on the console well past 999 in the first few seconds and I haven't even done anything yet. Also, the name doesn't make sense. My character name is Mercivus and when it prints out ability.name that's what it prints. Does this make any sense to you?

    [EDIT]
    I tried in the Adventure scene with Naomi and I see the same thing. It thinks all the abilities are names Naomi and it runs that function constantly.
     
    Last edited: Apr 6, 2018
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    In TryStartAbility it's aborting on the following condition:

    (i < ability.Index && !ignoreLocalPriority)

    In this case i = 0 and ability.index = 1. I checked and the Fall ability was higher priority than Jump. When I swapped them then it worked. So, I finally solved this. But how this has anything to do with having the Maximize On Play set is beyond me.
     
  10. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I started debugging the issue with frame rate drops when jumping and it seems directly related to the GroundCheck functionality/ When in the air, the controller is constantly doing the Physics.SphereCast calculations and when indoors this affects a lot of geometry and is super slow. I did some experimenting where I moved the check to a Coroutine and only fired it every .1 or .5 seconds. The longer I delayed, the more the frame rate issue disappeared. However, not checking as often as necessary had side-effects like not knowing exactly when to stop the jump ability.

    It seems to me that another mechanism could be used here instead such as simply flagging the character as grounded when it trigger collides with some geometry underneath it. So instead of actively and aggressively checking, it would be a more passive check. There are probably challenges to this sort of approach, but I'm going to have to try to implement something like this or suffer really bad performance issues.
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I just found out that the same thing happens when in Crouch mode. If I crouch and don't move then the frame rate drops by over 25. When moving while crouched the frame rate drops by "only" about 10 fps. This is very disappointing results. I would very much like to get this resolved if possible.
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Can you post the results from the profiler?

    The grounded check is performed whether the character is on the ground or in the air so I don't think that's what you're seeing. I've never developed on the Wii U before so I don't know the specifics but this is only one cast per frame which is generally pretty cheap. If you do want to modify it though I would first try to change the LayerManager.Mask.Ground layermask to fit your setup better.
     
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,736
    I can't remote profile on the Wii U so I can't get the results unfortunately. I'm putting this issue aside for now and will get back to it later. I'll let you know when I get back to it.
     
  14. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    319
    Hi,
    what is the initialization process of the rigidbody character controller and the camera controller? When I start with both active all is ok, but as soon as one or the other is not active when started or one gets disabled a frame after start there are errors, ability animations don't behave as they should...

    Are there any docs on initialization of components from code?
    I'm partway there, but then when I disable the character the weapon child stops receiving OnAnimatorItemEndUse because you deactivate it in ondisable but never reactivate it when the character is enabled again, I think the inventory is not reinit so you don't reequip the item and it gets stuck in the use state when used

    please check in Item:
    private void OnDisable () {
    // Stop the item from equipping or unequipping when disabled. This prevents the character from trying to unequip after a respawn if the item was switched just
    // before death.
    m_IsEquipping = false;
    m_IsUnequipping = false;
    if (m_Controller != null) {
    //ItemDeactivated();
    }
    }
     
  15. David5988

    David5988

    Joined:
    Sep 9, 2011
    Posts:
    140
    This sounds like the tool I needed to improve my character controller. Is this compatible with UWP?
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    When the camera starts it'll call InitializeCharacter to initialize the character. This in turn will initialize the camera and register the camera for any events. Meanwhile the CharacterHandler will call Utility.FindCamera to find the camera that is initialized to a specific character. This allows the character to know which camera it is using.

    What are you trying to initialize? For the most part all of the components will initialize automatically.
    Can you list the steps to reproduce from a fresh that is causing a problem? ItemDeactivated isn't commented out in the released version and should be done when the character is disabled.
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Awesome - yes, it is :)
     
  18. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    319
    the character/camera pair.
    I was asking because when I deactivated both and later reactivated the character got stuck in an animation, but found this to be a result of this ->

    just start with a camera and a character. have the character start with an item and have the item be the child of the character. then deactivate both and reactivate both. the animation is stuck at the end of the use state
    I commented ItemDeactivated out, with it commented out the animation works as it should after those ^ steps
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Ah, I see. Thanks for the steps. Add the following commented line to AnimatorMonitor.OnEnable and you shouldn't need to uncomment that item line:

    Code (csharp):
    1.  
    2.             if (m_ActiveStateHash != null) {
    3.                 for (int i = 0; i < m_ActiveStateHash.Length; ++i) {
    4.                     m_ActiveStateHash[i] = 0;
    5.                 }
    6.  
    7.                 PlayDefaultStates(); /// HERE
    8.             }
    9.  
     
  20. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    319
    would it be possible to add a camera shake to the camera controller?
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Right now that'll require modification within the CameraController. In version 2 we have a new concept called Effects which is a beefed up version of the camera effect system in UFPS so it'll be much easier to add then.
     
  22. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    319
    is it a lot of modification? could this make its way into v1 (just shake, not the effects)?
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    The earthquake effect is the most similar to a camera shake and it uses the spring system brought over from UFPS so that won't be able to be brought to v1. A simple camera shake though would be pretty basic to add, for example:

    https://gist.github.com/ftvs/5822103

    This could be added to the end of the CameraController.Move method:

    Code (csharp):
    1.  
    2.             var shakeDelatPosition = Random.insideUnitSphere * shakeAmount;
    3.             shakeDuration -= Time.deltaTime * decreaseFactor;
    4.  
    5.             // Set the new position.
    6.             m_Transform.position = Vector3.SmoothDamp(m_Transform.position, targetPosition, ref m_SmoothPositionVelocity, m_ActiveState.MoveSmoothing) + shakeDeltaPosition;
    7.  
    The variables need to be added but it should give you an idea on how to approach this.
     
  24. UDN_449900de-7c34-4a67-83eb-fa8501bf0413

    UDN_449900de-7c34-4a67-83eb-fa8501bf0413

    Joined:
    Jun 16, 2017
    Posts:
    16
    Intergrate Ultimate Survival plz :D that could be awesome :D
     
  25. RemitPrime

    RemitPrime

    Joined:
    Apr 20, 2016
    Posts:
    21
    Im planning to purchase.


    Any eta for photon multiplayer ?
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    I purchased Ultimate Survival for this exact purpose but unfortunately Ultimate Survival isn't very extensible so integration with it isn't planned at this time.
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Thank you!

    I have heard of people getting the existing version to work with Photon PUN, but official support for PUN won't be until version 2 and the multiplayer addon. However this addon is currently blocked by a Unity bug so I haven't been able to work on it recently - please vote on the issue here:

    https://issuetracker.unity3d.com/issues/animation-animator-transition-does-not-get-interrupted

    This post also has more info:

    http://opsive.com/forum/index.php/topic,5525.0.html
     
  28. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    Hi, purchased the kit recently, looks great. Much more polished overall than the other third person controllers I have demoed.
    I have a question about the movement when running and looking. The body of the player character shifts across the screen when moving right to left and fixed that with putting the main camera as a child of the character.
    Also, then looking around there is some sort of delay in the scene, i assume smoothing, but I want it to have no delay or "rebound" when the player stops looking around. Is there a setting to do this? I want there to be no additional movement and would like the camera to look exactly where they look without any additional effects.
    Any input would be greatly appreciated. Thanks!
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Awesome to hear!

    Both of these sound related to the movement smoothing - under the Movement Options foldout of the camera state you'll want to set a smoothing value of 0.
     
  30. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    Thanks so much. One other thing, there is a delay after the jump where the character is not moving, can I configure this to be continuous instead of the delay?
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    That's related to the animation - if you switch out the animation with a jump that doesn't have the delay you'll be good to go.
     
  32. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    Awesome, thank you for the feedback. Really liking the integration so far and the more I learn about it the more I like it. Keep it up.
     
  33. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    I am running into trouble getting the crosshairs to display in game. I have setup the crosshairs on the weapon to match the crosshairs of the assault rifle in the demo, and have also created a canvas object with the crosshairs child and top,bottom,left,right images as it is setup in the demo. When i press play nothing is showing up. I have ensured that the layer is set to UI for the canvas as well but not sure what I am missing here?
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Make sure you follow these steps when copying the UI:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=102
     
  35. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    worked thanks, not sure how i missed that in docs, i was searching for "crosshair".

    I do have a few questions about the bullet physics, i have a projectile being shot (just a primitive cube) at a rate of 200 and it doesn't seem to register the sprite and smoke for bullet hit consistently, it happens more at certain places which makes me think that it is moving too fast to register the collision on the surface i am looking at. is there a way to make this more consistent?
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
  37. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    Awesome thanks again.
    I have turned root motion off from for character movements, on up-slopes it seems the walk speed is much slower than on down slopes and flat land. I would like the walk speed to be consistent up or down ramps (i have 45° ramps and set slope limit to 55 and step height .2) . Is there a setting I can modify to accommodate this?

    **edit** also when strafing sideways on a 45 degree it actually falls backwards and sideways at the same time but would like to just move sideways. it seems the slope is effecting the movement but i would like it not to, is there a setting?
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    The controller uses rigidbody physics so it's dependent on how the rigidbody works. You could create an ability which accounts for the slope and then adds an extra force based on that, but there isn't anything built in.

    Version 2 uses a kinematic character controller which allows for more precise control in situations like this and the speed is constant when moving on slopes.
     
  39. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    When is release date for version 2? is there a beta test group that I would participate?
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
  41. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    I am having some troubles getting the tracer to appear properly on the hitscan options for my assault rifle. Are there any premade tracer components that would work well? basically i just made a stretched billboard with .2 second lifetime but the particles are starting way behind me even with the tracer location using the same point as the fire point and the correct direction. any tips on this one?
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    I actually don't think any of the weapons in the demo scenes use the tracer feature of the hitscan weapon. I've made a note to add it to the next release. The Deathmatch AI Kit does have a weapon which uses this feature though and this is what it looks like:

    hitscanoptions.PNG

    tracer.PNG

    The TracerLocation is at the same location as the fire location.
     
  43. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    Perfect, thank you. This works pretty well.
     
  44. Cartoon-Mania

    Cartoon-Mania

    Joined:
    Mar 23, 2015
    Posts:
    309
    Please tell us about 2.0. When do you expect to release?
     
  45. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    opsive likes this.
  46. EdBoon

    EdBoon

    Joined:
    Nov 24, 2014
    Posts:
    139
    The jump behavior when on a slope is interesting in my build. When i just while walking up a ramp, the character enters the jump animation, but still continues to slide up the ramp, when the end of the ramp is reached, the character is pushed up like the jump button is pushed, but it had been pushed down further on the ramp not at the top. Are some of the settings wrong in this case or what is causing this "double jump" behavior?
    Thanks
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Hmm.. Are you able to reproduce this in the clean scene so I can take a closer look at what's going on? If you set a breakpoint/Debug.Log in Jump.StartJump you'll be able to see if jump is being called a second time but it doesn't sound like it is in this case.
     
  48. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    82
    Is there a command to temporary set a 'look at' point for the player and setting it to null when the distance is too far?
    Code (CSharp):
    1. void Start ()
    2. {
    3.      Player = GameObject.FindGameObjectWithTag("Player");
    4. }
    5. void Update ()
    6. {
    7.      var Distance = Vector3.Distance(this.transform.position, Player.transform.position);
    8.      if (Distance<=2.5f)
    9.      {
    10.          Player.GetComponent<Opsive.ThirdPersonController.CharacterIK>(). ???
    11.      }
    12. }
     
  49. immFX

    immFX

    Joined:
    Mar 20, 2010
    Posts:
    108
    Anybody tried version 1.3.9 with the new Unity 2018.1? Were there any issues?
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,725
    Yes - version 1.3.9 works well with Unity 2018.1.
     
    immFX likes this.
Thread Status:
Not open for further replies.
unityunity