Search Unity

3rd Person Camera - emulating the World of Warcraft camera with Smart Pivot and Thickness Checks

Discussion in 'Assets and Asset Store' started by Enzi, Feb 3, 2016.

  1. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959

    If you're looking for an easy to use 3rd person camera that emulates cameras in AAA productions like World of Warcraft and Guild Wars 2 look no further!

    The main feature points of this asset are:
    • Occlusion Checking
      A spherical collision algorithm makes sure the camera doesn't clip into any geometry and repositions itself when the target is obstructed.
    • Smart Pivot

      Sets a pivot point when the camera is hitting the ground while looking up and prevents the character from blocking the view.
    • Thickness Checking Thickness checking can be configured to ignore smaller obstacles like sticks, trees, etc... to not reposition or zoom in the camera.
    • Controller support
    Its flexibility also allows to implement different camera modes. For example, over-the-shoulder type of games like Dark Souls.
    Also it has no other script dependencies, is easy to configure and open source.

    Assetstore: https://www.assetstore.unity3d.com/en/#!/content/47601
    Documentation: http://bit.ly/1p2BTSi
    Beta: http://www.enzenebner.com/beta
    WebGL Demo: http://enzenebner.com/camera/
    !Attention! The WebGL version has a glitch with mouse locking. If you don't press any key while the mouse is hidden it will leave the window.
     
    Last edited: Apr 5, 2019
  2. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    As part of the 1.0.3 update I added an automatic follow mode. It works without any manual camera handling and is designed for something like handling a car, tank, plane, etc...

    The slope alignment works best with non-humanoid characters.

    Here's a demonstration:


    With 1.0.3 it will be built-in. For now, here's the code to extend the 3rd person camera.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Follow : MonoBehaviour
    5. {
    6.     public bool follow = true;
    7.     public bool alignOnSlopes = true;
    8.     CameraController cc;
    9.  
    10.     void Start()
    11.     {
    12.         cc = GetComponent<CameraController>();
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.         if (follow)
    18.         {
    19.             RaycastHit raycastHit;
    20.             Vector3 upVector = Vector3.up;
    21.  
    22.             Quaternion toRotation = Quaternion.LookRotation(cc.target.transform.forward, Vector3.up);
    23.  
    24.             if (alignOnSlopes)
    25.             {
    26.                 if (Physics.Raycast(cc.target.transform.position, Vector3.down, out raycastHit, 15.0f, (1 << 0))) // if the range of 15.0 is not enough, increase the value
    27.                 {
    28.                     upVector = raycastHit.normal;
    29.                 }
    30.  
    31.                 float angle = AngleSigned(Vector3.up, upVector, cc.target.transform.right);
    32.  
    33.                 toRotation = toRotation * Quaternion.AngleAxis(angle, Vector3.right);
    34.             }
    35.  
    36.             cc.transform.rotation = Quaternion.Slerp(cc.transform.rotation, toRotation, Time.deltaTime);
    37.         }
    38.     }
    39.  
    40.     public float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n)
    41.     {
    42.         return Mathf.Atan2(
    43.             Vector3.Dot(n, Vector3.Cross(v1, v2)),
    44.             Vector3.Dot(v1, v2)) * Mathf.Rad2Deg;
    45.     }
    46. }
     
    Last edited: Feb 16, 2016
  3. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    1.0.3 was submitted and will be soon released on the asset store!
    It's a bulky update, with 2 new demo scenes that feature an auto follow demonstration with a car and a freeform camera plus lock-on targeting. 2 features that were much requested.

    Thickness check and smart pivot, 2 features that are still unique to any other camera on the asset store also got improved further.

    With the new features and changes I'm also upping the price to 25$. So if you were interested before, grab it will it's 10$ cheaper!

    As mentioned in my initial post you can always get an up-to-date version of the WebGL demo, featuring the 2 new scenes.
    I also made some videos demonstrating everything the asset has to offer.

    Freeform camera demonstration:


    Follow mode:


    Freeform + lock-on targeting
     
  4. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    1.0.3 has been released!
     
  5. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    1.0.4 is in the works with the following changes:

    - added smart DisableFollow script to utilize FreeForm + Follow
    - added Ball demo scene (not playable right now in WebGL)
    - added simple BallController script
    - added namespace to scripts
    - improved smart pivot transition from sloped surfaces
    - improved smoothness of alignToSlopes feature
    - improved camera when target offset clips into geometry
    - restored Ethan crouch animation
    - removed Ethan air->ground crouch animation

    While I'm setting an automated process up to get access to betas, you can send me an email with your invoiceID to verify.
    When it's done the betas can be found on: http://www.enzenebner.com/beta
     
    Last edited: Mar 5, 2019
    Bhanshee00 likes this.
  6. Deleted User

    Deleted User

    Guest

    how to make a programming
     

    Attached Files:

  7. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    I'm currently updating the 3rd person camera asset with some new features:
    - smooth target following with speed value
    - additional camera offset to better emulate over the shoulder type of games which have their pivot not around the character

    On the horizon is an update to make use of ECS and the ability to use multiple cameras but that's a feature I'm not sure is even wanted. Let me know in any case.

    edit: I'm sorry for the broken Youtube links. Something seems to be going on in the forum.
     
  8. hendrikk1

    hendrikk1

    Joined:
    Aug 7, 2012
    Posts:
    15
    Hi Enzi,

    Your asset works well in my game, thanks for making it! But since you're planning to update it with the additional camera offset like you mentioned, when will it be ready to download ?
     
  9. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Hey Hendrik!
    I just came back from a business trip, otherwise I would've replied sooner.
    I'll make the beta package available the next days or this weekend. There's a hiccup I need to iron out with the camera offset and smart pivot enabled. Other than that it's already working.
     
  10. hendrikk1

    hendrikk1

    Joined:
    Aug 7, 2012
    Posts:
    15
    Thanks for the reply, Enzi, let me know when the beta ready :D
     
  11. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    1.0.5 is now available
    You can find it with this link and your OR number: http://www.enzenebner.com/beta
    The OR number is found in the Unity receipt when purchasing the camera.

    1.0.5 brings the following changes and features:
    - added additional camera offset vector for skewed over-the-shoulder camera type of games like "The Division"
    - changed PlayerLayer data type to LayerMask
    - added "Smooth Target Mode" and "Smoothing speed" that lerps to the target position for smoother translations/rotations
    and to dampen noisy position changes
    - added new scene to demonstrate Camera Offset

    I'll provide a short video to show off the new camera offset as it's easier to understand what this really means. Basically the pivot is usually at the characters head but for over-the-shoulder games the pivot is actually in the middle of the screen with the character to the side.
    With the new camera offset vector this can be changed easily now. Before, when you moved the offset to the left or right it ended in odd rotations that were not good for such a type of camera or game.

    I hope that is fixed now and the camera support even more games.
    I'll test further and if everything is alright the package gets submitted to the store.
     
    Last edited: Mar 30, 2019
  12. hendrikk1

    hendrikk1

    Joined:
    Aug 7, 2012
    Posts:
    15
    Hi Enzi,
    Thanks for the update, for the OR number, is it the one with '#' character at first or with 'IN' ?
     
  13. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Sadly there's a problem with the beta access. New order numbers from the store don't work anymore and I've to find a new solution and rewrite the backend.
    In the meanwhile, for anyone interested, send me a PN or an email with your reciept and I'll give you access.

    edit: Beta access if fixed now
     
    Last edited: Apr 5, 2019
  14. digitalzombie

    digitalzombie

    Joined:
    Dec 10, 2007
    Posts:
    86
    Great camera! I purchased last night and within an hour or so had exactly the camera I wanted. 5 stars!

    Just a comment for your consideration, I did make 2 modifications.

    1.) Added minimum and maximum zoom distance variables and code accordingly. I didn't like being able to zoom in to 0 and zoom out with no limit on distance away from my character.

    2.) Removed the CursorLock code so that I could click buttons with the freeform component enabled. Clicking was turning on freeform and moving the cursor to the center of the screen so my buttons were never being clicked.

    .Thanks!
     
  15. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Thank you very much! Also for the 5 star review. Much appreciated!

    1) Yeah, why is this not a setting in the first place? I'll add this in 1.0.5
    2) I see, the UIHandling is quite old to be honest and relies on colliders which it totally outdated in uGUI by now. I'll update this too, that way it should work out of the box when using uGUI.
     
  16. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    I've fixed the beta access for newer order numbers. (parsing to integer wasn't that clever)
    You can download the beta via order number or the invoice number. Both should work.
     
  17. alexbu92

    alexbu92

    Joined:
    Apr 7, 2019
    Posts:
    2
    Very interested in this asset. Is it possible to set up a camera like Rocket League's free form camera with this? (
    , which is basically a third person camera that follows the player but points in the direction the player is moving, not necessarily facing). How much is it off? Your collision sensitivity is definitely a must, but how much is missing to get to that kind of camera behavior? Thanks in advanced.
     
  18. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Hey Alex!
    Thanks for your interest. TBH, if you want to recreate something very similar to the video you've shown me I'd not bother with camera collision and focus more on a script that is does a fine-tuned lerped Quaternion.LookRotation.

    If you do need collision.There is a script that follows any target and lerps to the forward vector of the target. In your case the forward of the car is not wanted so the solution is to make another gameobject (I call it "SlowFollowTarget") that is the target of the camera and its position is interpolated from the car.
    That way everything is decoupled and can be tuned individually.

    This SlowFollow script can be as simple as:
    Code (CSharp):
    1.  
    2. public class SlowFollow : MonoBehaviour
    3. {
    4.     public Transform target;
    5.  
    6.     public float speed = 1.0f;
    7. public float rotationSpeed = 1.0f;
    8.  
    9.     void Update()
    10.     {
    11.         transform.position = Vector3.Slerp(transform.position, target.transform.position, Time.deltaTime * speed);
    12. transform.rotation = Quaternion.Slerp(transform.rotation, target.transform.rotation, Time.deltaTime * rotationSpeed);            
    13.     }
    14. }
    In any case, you probably want to extend this to fit your game and car speed, have different thresholds for example.
     
  19. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    414
    Does multi camera?
     
  20. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Hey, does it work with this sort of field of view?
    WD.jpg WD.jpg
     
  21. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Yes, this type of camera is possible with the 1.0.5 beta where I've added an additonal camera offset.
     
  22. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    1.0.5 has been submitted with the following changes:
    • added an additional camera offset vector for skewed over-the-shoulder camera type of games like "The Division" that can either be fixed or controlled via the OverTheShoulder script
    • added OverTheShoulder component
    • added new scene to demonstrate Camera Offset called "DivisionCamera - DemoScene"
    • changed PlayerLayer data type from integer to LayerMask for convenience and the possibility to have more player layers
    • added "Smooth Target Mode" and "Smooth Target Value" that lerps to the target position for smoother translations/rotations to dampen noisy position changes for either physics or network based games
    • added support for having no target when initializing or starting
    • added mouse/keyboard inputs to FreeForm which uses a list of mouse buttons (Integer) and keyboard inputs (KeyCode)
     
  23. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    I've submitted the package in Unity 2019.3 which broke backwards compatibility.

    I'm sorry for that and have submitted the asset again, now with Scene and Prefabs that are backwards compatible down to Unity 2017.1 and should go even lower to Unity 5.x but I haven't tested that.

    For anyone who has already bought the asset and doesn't want to wait, I've attached the releveant files in this post.

    edit: New version has been published on the asset store.
     

    Attached Files:

    Last edited: Sep 10, 2019
  24. layzrr

    layzrr

    Joined:
    Dec 8, 2016
    Posts:
    1
    Hey Enzi - first off, thanks for putting together this great asset. Saved me a lot of headaches.

    I was hoping I might find help with a particular use case. Basically, I'm interested in manually setting the camera's orientation, or "reinitializing" it. For reference, in my project, the player can fall off of the playfield, which will reset them to a specified point on the map. As part of this, I'd like to align the camera behind them so that it is facing towards the goal, which will be in an arbitrary direction.

    I've tried fiddling with the camera position manually, LockOnTarget's followTarget, and disabling FreeForm's cameraEnabled before setting the position (and re-enabling after) to no avail. When my character is moved, the camera is always in the same orientation it was from before the reset.

    Is what I'm trying to accomplish doable? How can I align the camera behind my player for any givent target/vector?
     
  25. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Yes that's possible in 2 ways, dependent if you use the Follow script or not.

    With no follow script you can set the rotation directly which means you can apply a Quaterinion.LookRotation with your vector to the main camera.
    With the follow script attached you have to rotate the forward vector of the target where it should look.
     
  26. GreenSignalGames

    GreenSignalGames

    Joined:
    Jul 11, 2017
    Posts:
    6
    Did #1 ever get added? I can't find a setting for this.
     
  27. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Thanks for reminding me. That change slipped through in the asset store version, sorry.
    It's in the updated beta package which can be found here: http://www.enzenebner.com/beta
    It'll be updated in the next few days.
     
  28. GreenSignalGames

    GreenSignalGames

    Joined:
    Jul 11, 2017
    Posts:
    6
    Thanks!
     
  29. GreenSignalGames

    GreenSignalGames

    Joined:
    Jul 11, 2017
    Posts:
    6
    I spoke too soon. I'm still not finding it in the Beta. Where is it hiding?
     
  30. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    edit: I'm sorry, not your fault. I made a mistake with the export, was getting late yesterday. The beta package should work now!
    I still question my implementation, or if it should move to CameraController. Let me know how it works out for you.

    It's in the FreeForm component:
    upload_2019-12-5_17-1-17.png
     
    Last edited: Dec 5, 2019
  31. GreenSignalGames

    GreenSignalGames

    Joined:
    Jul 11, 2017
    Posts:
    6
    Ah, there we go. Thanks! Great asset, great service, you get a gold star. 5 of them, actually. :D
     
  32. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Thank you, glad to hear that!
     
  33. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    Hi,
    In third person Camera (Dark Souls Camera) if I Set the settings as below and when I am close to the target.
    The camera slowly moves on top of the target and starts rotating.

    For a Dark Souls Camera, the Camera should always remain behind. Not Touch the ground or move on the top.

    Request your help.
    Thank you.
     

    Attached Files:

  34. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    I see you have a large y offset, you can merge this into one offset. In your case you can set the offset vector to 0/2.5/0 and the camera offset vector to 0/0/0.
    Also important is to have normalized values for this. So, if you have a 2.5 offset the Targetable offset should also be 0/2.5/0.

    Hope this helps!
     
  35. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    Hi,
    Thanks for your replies.

    Please refer this video for the problem that I am faching.


    Similar issue can be replicated on the WebDemo.
    1. Target is selected.
    2. Player moves close to the target and goes on the other side of the target, slowly.
    3. In the WebDemo, the camera touches the ground and zooms close to the player and goes to the other side from undernearth the player.

    I would like to have the camera move in an angle ( 45 ° prespective) around and looking at the player. Desired movement required as per image.
    The camera should never go over the top or touch the ground when player is close to the target.


    Thanks in advance.
     

    Attached Files:

    Last edited: Feb 5, 2020
  36. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Can you try setting the Targetable offset to 2.5, same as your camera controller offset?
    upload_2020-2-5_14-23-21.png

    That way the camera will stay on the same plane and never look up or down and it should result in the movement you have shown me in the picture. In the tests I did, the camera moves around the target in an arc.

    What also helps is setting the Rotation Speed of the Lock On Target script to something like 7 as it's rather slow moving otherwise.

    Let me know if this helps!
     
  37. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    Thanks for all your replies..
    I followed your suggestions.
    Now it works as smooth as butter. :)
     
    Last edited: Feb 6, 2020
  38. Voodux

    Voodux

    Joined:
    Feb 2, 2016
    Posts:
    7
    Hi Enzi,

    Im thinking about buying the asset. Looks very good and professional!

    1 question, is it possible to make the camera like in this youtube clip? Out of the box or with some coding?



    Thank you!
     
  39. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Yeah, the camera functionality for something like Socom2 works out of the box.
     
  40. Voodux

    Voodux

    Joined:
    Feb 2, 2016
    Posts:
    7
    Great! Thanks
     
  41. Voodux

    Voodux

    Joined:
    Feb 2, 2016
    Posts:
    7
    Wel.. I bought it and tried it but out-of-the-box.. I could not get it the same as the YouTube video unfortunately.

    Movement should be (f.e using a X-box controller):
    Left-stick:
    - left Strafe Left
    - right Strafe Right
    - up Move Forward
    - down Move Back (player walks backwards)

    Right-stick:
    - left Rotate player left
    - right Rotate player Right
    - up Make Camera Look Up
    - down Make Camera Look Down

    * Camera is always behind the player, looking over the shoulder. So you should not be able to see the players face.
    * Player turns with turning the Camera

    Maybe use the DarkSoulsCamera and change the Animations on the player when Left-stick left/right/back? Now the player turns towards the direction the player moves instead of strafing.

    Only problem is when turning the Camera, the player should turn too.
     
    Last edited: Mar 6, 2020
  42. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Thanks!
    I'm sorry for my hasty wording. The camera and character controller are 2 seperate things.
    The Ethan model certainly has to be replaced with a model that has proper animations. This Ethan doesn't have strafing left/right animations so it's forced to "just" turn.

    Do you have a good character controller and model you can replace it with?
    I usually have this functionality in my character controller but it's also a good option to have in the camera.
    I added a "Force Character Forward" to FreeForm, although it doesn't play nice with the current character controller for Ethan and how he is setup. (He only moves forward when enabled)
    You can access this change via your OR number: http://www.enzenebner.com/beta

    I've implemented this in the past with a custom character controller and Mixamo animations with strafing and all, so if you feel unhappy about this or are stuck somewhere, please contact me via email and I can help you out. I should be able to rip out a project of mine with the proper animations.
     
  43. Voodux

    Voodux

    Joined:
    Feb 2, 2016
    Posts:
    7
    Thank you for the quick and good reply! I will play around with it.
    Ill give the option "Force Character Forward" from tge beta version a go.

    Edit: the "Force Character Forward" option does make the character rotate when the camera rotate! Also what you said about the current character controller not working properly now is correct. Thank you for being so responsive! Really excellent service.
     
    Last edited: Mar 6, 2020
  44. freze00100

    freze00100

    Joined:
    Jul 2, 2019
    Posts:
    9
    Hey guys can someone help me with a little problem. basically everything work fine on the demo scene but when i try to use it on my own the camera left the player and stops following. has anybody run in to this problem ?
     
  45. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Hey!
    Did you set the Player Layer or your target?
    playerLayer2.png
     
  46. freze00100

    freze00100

    Joined:
    Jul 2, 2019
    Posts:
    9
    yeah my bad. i was using a weather system that had a collider i just needed to change the layer of that collider it works perfectly fine. good asset
     
  47. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Glad to hear, thank you!
     
  48. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    Hey there, loving the camera system so far!
    I was just wondering if there is an eta on target switching with the lock on camera?
    I'm trying to add the feature myself at the moment, but it's proving a little difficult. My initial thought was to run the targetabledistance loop again but with the distance from the current followTarget. From there I'm kinda stumped on how to determine, based on input, which targetable object to switch to.
     
  49. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    959
    Hey! Thanks a lot!
    I'm working out the last TODOs in the LockOnTarget script. I'll keep you posted. When it's done I'll push it to the beta area so you can get immediate access.
     
    Pixelith likes this.
  50. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    Sounds awesome!
    I thought I almost figured it out last night taking the inversetransformpoint of the camera and seeing which object is closest to the follow target but to the right of the camera. In tests it only worked maybe 4/10 times. So I'm really happy to hear these features are close to done.