Changing state by code

dasjlm

Member
The following example code from your site gives me an error. I assume your aware it doesn't work as is as the GetType is a problem.


using UnityEngine;
using Opsive.UltimateCharacterController.Camera;
using Opsive.UltimateCharacterController.Utility;

public class MyObject : MonoBehaviour
{
[Tooltip("The character that should be assigned to the camera.")]
protected GameObject m_Character;

/// <summary>
/// Sets a third person perspective on the Camera Controller.
/// </summary>
private void Start()
{
var camera = UnityEngineUtility.FindCamera(null);
if (camera == null) {
return;
}

var cameraController = camera.GetComponent<CameraController>();
cameraController.Character = m_Character;
cameraController.SetPerspective(false); // false indicates the third person perspective.

// Switch to the third person Combat View Type.
var viewTypeName = "Opsive.UltimateCharacterController.ThirdPersonController.Camera.ViewTypes.Combat";
cameraController.SetViewType(UnityEngineUtility.GetType(viewTypeName), false);
}
}



Do you have an updated version that shows how to change the view type by code?
 
Thanks, I'll update it. The Utility classes have moved to the Shared namespace.
 
Top