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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Third person RPG-like examples?

Discussion in 'Cinemachine' started by mons00n, Apr 10, 2018.

  1. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    299
    Hi everyone. I've recently started toying with Cinemachine and it's shaping up to be a fantastic tool. I spent a good few days choreographing camera movements for our character creation/selection with good ol' coroutines and I was able to switch to using Cinemachine in a matter of minutes.

    However, I have yet to find any good examples on a third person RPG-like controller. Everything I have found thus far points to using the FollowCam etc. I have a "working" example where I moderate the speed of the x/y axis based on if the right mouse button is held, control zoom via changing the radius of the high/med/low cameras based on the mousewheel, etc. But things still just feel a little "off" and I can't quite find a combination of settings that feel right.

    Does anyone know of (current assets, free or paid), or is willing to share examples of their third person controllers with Cinemachine? I did find this tweet from @Adam_Myhill but the link is dead =(
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,208
    Can you elaborate a little on what you mean by "feels off"? I'd be happy to help you tweak your cam to get it right if I could know a little more about how it's wrong.

    Could you upload a simple project with your cam in its current state, so we could exchange some ideas?
     
  3. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    299
    Hi Gregoryl. Thanks for the speedy response and apologies for my delayed one! I think a lot of the odd feeling comes from not having the movement cohesive with the camera movement; likely 100% my fault due to not fully grasping Cinemachine settings.

    I'm currently using the CinemachineFreeLook component with the following settings:
    Y-axis: Accel Time=0.2, Decel Time=0.1
    X-axis: Accel time=0.1, Decel Time=0.1
    Heading: Heading Definition="Target Forward", Velocity Filter=4, Heading Bias=0
    Orbits: Binding Mode="Lock To Target On Assign", Spline Curvature=0.2

    All 3 rigs are using Orbital Transposer for the body and Composer for the Aim (no noise). The values for the height are all adjusted to the character's height, and the radius is controlled via mouse wheel. I then modify the x/y speed based on the status of the right mouse button like so:

    Code (CSharp):
    1.  
    2. if (m_playerEntity.InputManager.MovementInput.y > 0f)
    3. {
    4.     Vector3 forward = GameManager.MainCamera.gameObject.transform.TransformDirection(Vector3.forward);
    5.     forward.y = 0f;
    6.     forward = forward.normalized;
    7.     Vector3 right = new Vector3(forward.z, 0f, -forward.x);
    8.     Vector3 targetDirection = forward * m_playerEntity.InputManager.MovementInput.y + right * m_playerEntity.InputManager.MovementInput.x;
    9.     Quaternion targetRotation = Quaternion.LookRotation(targetDirection);
    10.     m_playerEntity.gameObject.transform.rotation = targetRotation;
    11. }
    12.  
    13. if (m_playerEntity.InputManager.HoldingRMB)
    14. {
    15.     m_playerEntity.FreeLook.m_XAxis.m_MaxSpeed = 300f;
    16.     m_playerEntity.FreeLook.m_YAxis.m_MaxSpeed = 2f;
    17. }
    18. else
    19. {
    20.     m_playerEntity.FreeLook.m_XAxis.m_MaxSpeed = 0f;
    21.     m_playerEntity.FreeLook.m_YAxis.m_MaxSpeed = 0f;              
    22. }
    23.  
    24. m_zoom = Mathf.Clamp(m_zoom - Input.GetAxis("Mouse ScrollWheel") * 0.1f, 0f, 1f);
    25.  
    26. for (int i = 0; i < m_playerEntity.FreeLook.m_Orbits.Length; i++)
    27. {
    28.     m_playerEntity.FreeLook.m_Orbits[i].m_Radius = m_playerEntity.OrbitRadii[i] + m_zoom * 8f;
    29. }
    30.  
    Which is basically saying: only move the camera when the right mouse button is held and the camera should steer the player if he is holding the right mouse button and they are moving forward. It "mostly" works but gets very quirky when strafing even though the follow target is still facing forward. Any tips/thoughts/advice on how you might improve this I would greatly appreciate it!
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,208
    Thanks for the description, but I'm still having trouble forming a concrete idea of what's wrong.

    It would really really help if you would make a little project, just a simple capsule or something for the player and nothing else in the scene, with your input and camera connected to it. Package it up, send it to me, and then we'll make some progress.
     
  5. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    299
    Fair enough. I am moving this weekend so it may take me a bit to package everything up and get it to you but will do it as soon as I can. Thanks again!