Search Unity

Third person cover controller

Discussion in 'Assets and Asset Store' started by EduardasFunka, May 23, 2017.

  1. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    In fact the AI must not crouch , if you scale a cover the AI will crouch.
    Standing cover, i mean the AI don't make any special cover move , it just runs behind a cover in standing position and ready to move anywhere. It's faster without needing to crouch that slows down AI.
     
  2. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    we removed a tall cover from a top down. I think it was working in one of the versions because we messed with github.
    the reason we removed because it a disadvantage to fight enemies in tall cover.
     
  3. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Anyone can make a level as he wish, some low covers in some areas, while tall covers in other areas.
    Tall covers can be big trees , buildings or anyhting else.
    If you can add a tall cover and AI able to use it, this would be great.
     
  4. IndieGeek

    IndieGeek

    Joined:
    Sep 30, 2016
    Posts:
    16
    Unable to build for mobile because of AISight class UnityEditor namespace issue. If I put the script in Editor folder then AI is not working as expected.
    Any solution?
     
  5. reddo1987

    reddo1987

    Joined:
    Aug 1, 2014
    Posts:
    35
    Hi guys,
    I have a problem with shooting behind the covers.
    When I try to shoot over the cover everytihn works fine but when my character try to shoot while he is under cover the bullets have a 90° angle and the head and the arms don't move. (See the attached video)
    How can I fix this?
     
  6. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    remove using UnityEditor; from AISight class
    and
    on drawFOV() change it to
    private void drawFOV()
    {
    var direction = _actor == null ? transform.forward : _actor.HeadDirection;
    var head = _actor == null ? (transform.position + Vector3.up * 2) : _actor.StandingTopPosition;
    direction = Quaternion.AngleAxis(-FieldOfView * 0.5f, Vector3.up) * direction;
    // Handles.color = new Color(0.5f, 0.3f, 0.3f, 0.1f);
    // Handles.DrawSolidArc(head, Vector3.up, direction, FieldOfView, Distance);
    // Handles.color = new Color(1, 0.3f, 0.3f, 0.75f);
    // Handles.DrawWireArc(head, Vector3.up, direction, FieldOfView, Distance);
    // Handles.DrawLine(head, head + direction * Distance);
    // Handles.DrawLine(head, head + Quaternion.AngleAxis(FieldOfView, Vector3.up) * direction * Distance);
    }
     
    IndieGeek likes this.
  7. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    possible causes :
    you have a player or Ai under the character .
    the Aiming system will auto aim at any object with the charactermotor script
    ... i can't think of anything else :p
    my guess is character prefab game object is active with ai inside
     
  8. reddo1987

    reddo1987

    Joined:
    Aug 1, 2014
    Posts:
    35
    My character prefab has the same components of "good guy" and there is nothing else on it.
    What you do mean with "you have a player or Ai under the character"?
    I have attached an image showing the inspector of my character.
    https://ibb.co/itWXZG --> image link

     
  9. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    upload_2018-1-27_10-19-42.png
    under that gameobject see if the cop , chief are active ?
     
  10. reddo1987

    reddo1987

    Joined:
    Aug 1, 2014
    Posts:
    35
  11. reddo1987

    reddo1987

    Joined:
    Aug 1, 2014
    Posts:
    35
    https://ibb.co/hzhEEG --> image link
    the cop, cop chief and soldier are disabled and they remain disabled when the cilivian call the enemies
     
  12. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    i'm not sure :(
    could you check the charactermotor IK , maybe the script missed a bone
    and the gun script too ,
    the only time this happed to me when i left an unused AI under the map
     
    Last edited: Jan 27, 2018
  13. reddo1987

    reddo1987

    Joined:
    Aug 1, 2014
    Posts:
    35
    Instead of creating a character from scratch, I tried to replace the "A good guy" asset this time, so I replaced the model, the bones in the IK and the weapons and now it's works. In the end I don't know what's happened with my previous character. Thank you for the assistance
     
    Rahd likes this.
  14. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    hello
    no news for AI forget player and Custom animation tool from 1.41 ????
    release date ?? thanks
     
    Rahd likes this.
  15. IndieGeek

    IndieGeek

    Joined:
    Sep 30, 2016
    Posts:
    16
    There is an error occurring "SendMessage OnSeenByFriend has no receiver!" when you make any patroller side to 1(same side as the player) and place that patroller with the player.
    Any solution?
     
    Last edited: Feb 3, 2018
  16. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    any news on the new update ?
     
  17. Alex-Slavski

    Alex-Slavski

    Joined:
    Dec 29, 2017
    Posts:
    4
    @IndieGeek @Rahd

    But this way you are actually disabling part of the functionality (I guess displaying field of view for enemies in the Editor, I have only just started tinkering with the asset). When you want to exclude only part of a script from running outside of editor you can enclose it in compiler flags.

    Code (CSharp):
    1. // Runtime code here
    2. #if UNITY_EDITOR
    3. // Editor specific code here
    4. #endif
    5. // Runtime code here
    So my code now looks like this:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. #endif
    Code (CSharp):
    1.         private void drawFOV()
    2.         {
    3.             var direction = _actor == null ? transform.forward : _actor.HeadDirection;
    4.             var head = _actor == null ? (transform.position + Vector3.up * 2) : _actor.StandingTopPosition;
    5.             direction = Quaternion.AngleAxis(-FieldOfView * 0.5f, Vector3.up) * direction;
    6.             #if UNITY_EDITOR
    7.             Handles.color = new Color(0.5f, 0.3f, 0.3f, 0.1f);
    8.             Handles.DrawSolidArc(head, Vector3.up, direction, FieldOfView, Distance);
    9.             Handles.color = new Color(1, 0.3f, 0.3f, 0.75f);
    10.             Handles.DrawWireArc(head, Vector3.up, direction, FieldOfView, Distance);
    11.             Handles.DrawLine(head, head + direction * Distance);
    12.             Handles.DrawLine(head, head + Quaternion.AngleAxis(FieldOfView, Vector3.up) * direction * Distance);
    13.             #endif
    14.         }
     
    IndieGeek likes this.
  18. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    He must be working on other plugins or projects.
     
  19. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    yeah , if you want to see the sight in runtime use sight script ,
    by the way i did that it #if UNITY_EDITOR but as soon as i build for android it will throw the error anyways for some reason :( not sure why
     
  20. Alex-Slavski

    Alex-Slavski

    Joined:
    Dec 29, 2017
    Posts:
    4
    Hmmm, I didn't try to make an android build with this, only desctop
     
    Rahd likes this.
  21. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Hi,

    in the topdown view, camera is always oriented from south to north where the UP control is heading north and for sure move the player forward. When you're heading south you press the DOWN control to move forward.

    But I'm trying to implement a camera button ( a bit like Xenowerk) where when you press it, camera will turn around so the player is always looking forward UP. Switching the cam is not my issue, but I can't have the controls to follow. UP is always pointing North.

    I'm sure it's not a big change, after all the 3rd person view is doing something like that but I can't just pinpoint where in the code.

    Thanks for your help
    Chris
     
  22. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    yeah it's tricky , and changing the camera script will make the controls upside down ...
     
  23. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    After making tests, I think the speed parameter in CharacterMotor script is useless (at least for player character). The case is I need to increase the movement speed but when setting higher than 1 the animation looks ridiculous. It is like in the old comic movies when they filmed in fast motion.
    In my opinion it is necessary to separate movement speed from animation speed.
     
    Last edited: Feb 15, 2018
  24. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    just head to https://www.mixamo.com and select the right animation and set animator the rule to play that when the speed value is right
     
  25. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    Thanks, but could you explain it more detailed, please?
     
  26. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    I think what @Rahd is referring to is the Overdrive setting in Mixamo. Moving it to the left will slowdown the animation.
     

    Attached Files:

  27. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324

    using the animator on the player you add new motion with a rule of pos y = 2 , 3 4 ...
    and if the speed is at that value the assigned animation will play
    you can tweek the animation and speed in more than one way
    1 you just change the walkspeed value on the script
    2 you change the animation speed in the animator
    upload_2018-2-16_14-16-20.png
    3 you change the whole animation with mixamo.com animations as christian explaind
    in the video i explained how you add a new rule so you can have multiple animations for different speeds , i find this to work best , as the walk or run animation will look normal not just a fast motion
     
    Last edited: Feb 16, 2018
  28. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    hello
    it will be nice to have news ..... 1.41 ...
    thanks
     
  29. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    The 1 and 2 solutions are useless because the movement speed is fixed with animation speed and vice versa.
     
    Last edited: Feb 17, 2018
  30. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    yeah i did point this out to the dev , the animations need to be separate of the walking .. and it should be a transforme transition.. to lower the lag , but he fixed the lag issue and the jerky motion ... so i'm not complaining.
    other things you can do is to lock the xz on animations (check bake) upload_2018-2-17_16-39-12.png
    and add a Transform.Translate script that will move the player overtime according to the walk speed

    or

    - you can try Accessing Transform in the Animation ,more infos on that :https://forum.unity.com/threads/accessing-transform-in-an-animation.431125/
    and change the upload_2018-2-17_16-49-14.png according to the walk speed in the late update.
    but again ,i did find adding custom animations for each speed value is the best will do a detailed video in that if you think it will help you more ,
    good luck
     
  31. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    Thank you very much. The developer told me he maybe will add a force multiplier to help with this issue...
     
    Last edited: Feb 18, 2018
    Rahd likes this.
  32. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    When you transition from left to right or forward or back there is a jerky delay in the animation that keeps this from being a really high quality asset. Running and gunning is really difficult. Does anyone know how to make that transition between quick left and right / forward and backward less jerky and more fluid / snappy?
     
  33. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    just keep the main animations you need ,
    you need to set your goals and select the animator and enter the unwanted animation or the one causing the problem and delete it :p , i did that for run left and run right to make the player slowdown when making turns,
    or edit the transition delay here (select the line , then uncheck fixed duration , then make it the way you want) : upload_2018-2-19_17-49-24.png
     
    Unplug likes this.
  34. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    1) Is anyone else having issues getting ahold of the developer and 2) is anyone else having issues with the plugin crashing Unity a lot? I've tried using this on two separate computers and 1 in 10 plays it crashes Unity. I've used Unity since version 2 and I have never had this issue.
     
  35. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Hi guys just noticed that this topic no longer sends me notifications about new posts. Will answer your questions now.
     
  36. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Culd you make short video so we talking about same thing
     
  37. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    We have some lag issues with 2017.3 waiting for unity to release a stable version. You can send me invoice and I will share code with u
     
  38. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    The MobileController has a hidden property called "Forward" that holds the up direction. The MobileCamera sets it every frame to be the same as it's offset from the visual target. If you are not using MobileCamera then you'll have to set the Forward value manually.
     
    f1chris likes this.
  39. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    There are two functions inside the FighterBrain, OnSeeActor and OnUnseeActor that record visibility events. If the actor is a friend they assume it's another AI and send the OnSeenByFriend and similar messages to it.
    You can try adding a SendMessageOptions.DontRequireReceiver to the calls that trigger the error. Otherwise, as as another temporary fix, try adding a disabled FighterBrain component to the player.
    Finally, we have fixed this issue in the upcoming update so such measures won't be necessary.
     
  40. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    Here is the issue. When you press A and then D to move left and then right, the motion is jerky and not fluid. The same goes for when you move forward and backward using W and S. I think this might be due to the binary nature of the keyboard input not giving a clean transition from one side to the other. This effectively makes combat really clunky and terrible as it's hard to do what people commonly do in fire-fights and that is to strafe. When it has slow, hard transitions like this, it makes game play feel just bad and unrefined. On top of that, when you do move left and right for some reason you also move backward even if you aren't pressing the S key. I think that this might be a combination of root movement.

     
  41. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Ok we will fix that once you press a and d without any delay so it will not go to idle state but transition to movement.
     
  42. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    Is there a quick update I can make on my end while I wait?
     
  43. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    @EduardasFunka

    I'm sorry to continuously post about this, but I believe I have found a bug that crashes Unity every time. It appears to be an infinite loop that occurs in AISearch - LIne 285 - while (cover.LeftAdjacent != null && !_usedCovers.Contains(cover.LeftAdjacent))

    It happens anytime I am near a cover and the AI is about to shoot at me or is shooting at me.

    I have been ripping my hair out trying to find out why this is happening.

    This is just one instance of the crash that I have experienced, I'm not sure if I am able to find other instances.

    Can you please advise on how to fix this?
     
    Last edited: Feb 23, 2018
  44. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    It looks like the bug is caused by a circular group of covers. If you are interested in the code, it basically takes a random cover, assumes it's a chain, finds the left-most cover in that chain and then checks every cover in that chain by going right.

    The bug is caused because presumably your level contains a chain that loops around. This was an oversight on our part and will be fixed in an upcoming update.

    To fix it right now, you can change the code around that line to:

    var starting = item.Cover;

    while (cover.LeftAdjacent != null && !_usedCovers.Contains(cover.LeftAdjacent))
    {
    if (cover.LeftAdjacent == starting)
    break;
    cover = cover.LeftAdjacent;
    }


    It basically remembers the starting cover, and stops the search for the left-most cover when it finds that starting cover again.

    Hope that helps.
     
  45. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    I get an error that says the name "starting" does not exist in the current context.

    Also, I am trying to figure out how to get a Pause to work without setting timescale to 0. I plan to add a boolean to the update functions for the character and AI. I see an AIController but it doesn't look like it's being used on any of your AI. Is there a simpler way to pause everything that I am missing?
     
    Last edited: Feb 24, 2018
  46. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    hello
    any news for 1.41?
    thanks
     
  47. MastermindInteractive

    MastermindInteractive

    Joined:
    Jun 13, 2014
    Posts:
    89
    Bump
     
  48. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Have you copied the code correctly? The "starting" variable is there at the top of it.

    To make sure it's the same. The code at the line 280 is

    if (_usedCovers.Contains(item.Cover))
    continue;

    After it we have

    var cover = Item.Cover;

    right after it there is a while loop.

    We want to replace that loop with that code. The new code should have a

    var starting = item.Cover;

    at the beginning, to remember the starting cover.

    The final code starting with the line 280 should look like this:

    if (_usedCovers.Contains(item.Cover))
    continue;

    var cover = item.Cover;
    var starting = item.Cover;

    while (cover.LeftAdjacent != null && !_usedCovers.Contains(cover.LeftAdjacent))
    {
    if (cover.LeftAdjacent == starting)
    break;
    cover = cover.LeftAdjacent;
    }

    var index = -1;


    Hope that helps.

    As for the AIController. The version you have contains two AI systems, a legacy one and a new one. AIController is from the legacy system which is removed from an upcoming update.
    To pause everything without using TimeScale you can use booleans, just as you plan to. However, keep in mind that the AI is split into many functional components, some of which have their own Update methods. I'd recommend simply getting all components inheriting from AIBase from a gameobject and disabling them during the pause. This will make sure you haven't missed any.
    We'll consider adding better support for pauses in the future, so such measures are less needed.
     
  49. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    if you want 1.41 send me invoice number.
     
  50. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    does it include melee ?