RCC V3

I have made sure that the Object Identifier is on the car with 14 as the number and its on a part of the car with a collider.

Hopefully you don't still have your issue... but I took a look at my EVP integration and I do NOT use an Object Identifier on the car at all. I can't imagine the integration is much different between RCC and EVP. So, I have to wonder if this is causing the issue possibly?
 
I know I am late to the party. Has anyone gotten this to work? I am attempting to get my character to get in and out of the car. I got the animations to flow through but the car becomes totally erratic and spins on the z axis. I have tried to find the part that would cause the issue but can not. I will post my code and hopefully we can work together to figure this out for all of us.
Info:
  1. Created a door open close animation for the drivers side door that matched the length of the Skycar ( I plan to do all doors on Layers and mask them so all doors can be opened independently once I figure getting in out together)
  2. I added the Move Towards Location script next to the drivers side door
  3. I did add the object Identifier to the left drivers side door.
  4. I turned on Log Events ticker on the character's Animation Monitor to see all Events during the sequence of events
 
Last edited:
C#:
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Demo.Car
{
    using Opsive.Shared.Events;
    using Opsive.Shared.Game;
    using Opsive.UltimateCharacterController.Character;
    using Opsive.UltimateCharacterController.Demo.UnityStandardAssets.Vehicles.Car;
    using Opsive.UltimateCharacterController.Objects.CharacterAssist;
    using UnityEngine;

    /// <summary>
    /// Provides a sample implementation of the IDriveSource.
    /// </summary>
    public class SkyCarCopy : MonoBehaviour, IDriveSource
    {
       [Tooltip("A reference to the colliders that should be disabled when the character enters the car.")]
        [UnityEngine.Serialization.FormerlySerializedAs("m_Colliders")]
        [SerializeField] protected GameObject[] m_DisableColliders;
        [Tooltip("The location that the character drives from.")]
        [SerializeField] protected Transform m_DriverLocation;
        //rcc
        [Tooltip("When the character is driving should the RCC Camera Controller be used?")]
        [SerializeField] protected bool m_UseCarCameraController = true;
        //
        private static int s_OpenCloseDoorParameter = Animator.StringToHash("OpenCloseDoor");
        private GameObject m_GameObject;
        private Transform m_Transform;
        private Animator m_Animator;
        private Rigidbody m_Rigidbody;
        private Collider[] m_IgnoreColliders;
        private CarUserControl m_UserControl;
        private AnimatorMonitor m_CharacterAnimatorMonitor;
        private int m_HorizontalInputID;
        private bool m_OpenedDoor;
        //rcc
        private RCC_CarControllerV3 m_CarController;
        private RCC_Camera m_Camera;
        private GameObject m_Character;
        private bool m_AutoFocus = true;
        //
        public GameObject GameObject { get => m_GameObject; }
        public Transform Transform { get => m_Transform; }
        public Transform DriverLocation { get => m_DriverLocation; }
        public int AnimatorID { get => 0; }
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        private void Start() // went with Start because that is what RCC used. Have to find out Whats the diff
        {
            m_GameObject = gameObject;
            m_Transform = transform;
            m_Animator = GetComponent<Animator>();
            m_Rigidbody = GetComponent<Rigidbody>();
            m_IgnoreColliders = m_GameObject.GetComponentsInChildren<Collider>();
            //ucc
            //m_UserControl = GetComponent<CarUserControl>();
            m_HorizontalInputID = Animator.StringToHash("HorizontalInput");

            //rcc
            m_CarController = m_GameObject.GetComponent<RCC_CarControllerV3>();
            if (m_CarController == null)
            {
                Debug.LogError("Error: The RCCDriveSource must be attached to a vehicle with the RCC_CarController attached to it.");
                return;
            }
            m_Camera = FindObjectOfType<RCC_Camera>();
            //Removed and swapped because RCC needed the items in EnableDisableVehicle
            // EnableDisableCar(false);
            EnableDisableVehicle(false);
        }
        /*
         * Removed because it only deals with the things taken care of by RCC
        private void EnableDisableCar(bool enable)
        {
            enabled = m_UserControl.enabled = m_Audio.enabled = enable;
            m_Rigidbody.isKinematic = !enable;
            for (int i = 0; i < m_Headlights.Length; ++i) {
                m_Headlights[i].SetActive(enable);
            }
            for (int i = 0; i < m_DisableColliders.Length; ++i) {
                m_DisableColliders[i].SetActive(!enable);
            }
        }
        */
        /// <summary>
        /// Enables or disables the car components.
        /// </summary>
        /// <param name="enable">Should the car be enabled?</param>
        private void EnableDisableVehicle(bool enable)
        {
            Debug.Log("Enable/Disable Run");
            //rcc
            m_CarController.enabled = enable;
            if (m_UseCarCameraController && m_Camera != null)
            {
                if (m_Character != null)
                {
                    // RCC's Vehicle Camera Controller can take control of the camera.
                    var cameraController = m_Character.GetCachedComponent<UltimateCharacterLocomotion>().LookSource as CameraController;
                    if (cameraController != null)
                    {
                        cameraController.gameObject.SetActive(!enable);
                    }
                }
                m_Camera.playerCar = enable ? m_CarController : null;
                // Set the AutoFocus so RCC doesn't start a coroutine when the camera is disabled.
                if (!enable)
                {
                    m_AutoFocus = m_Camera.TPSAutoFocus;
                    m_Camera.TPSAutoFocus = false;
                }
                else
                {
                    m_Camera.TPSAutoFocus = m_AutoFocus;
                }
                m_Camera.gameObject.SetActive(enable);
            }
            //UCC Skycar: This Automatically disabled all colliders on the car so I removed it
            //m_Rigidbody.isKinematic = !enable;
            /*
            for (int i = 0; i < m_DisableColliders.Length; ++i)
            {
                m_DisableColliders[i].SetActive(!enable);
            }

            if (m_CarController == null)
            {
                return;
            }
           */
    }
        /// <summary>
        /// The character has started to enter the vehicle.
        /// </summary>
        /// <param name="character">The character that is entering the vehicle.</param>
        ///
        /// Identicle code except Skycar Registers for event "OnAnimatorOpenCloseDoor" sent by Animation
        public void EnterVehicle(GameObject character)
        {
            Debug.Log("EnterVehicle Run");

            EventHandler.RegisterEvent(character, "OnAnimatorOpenCloseDoor", OpenCloseDoor);

            var characterLocomotion = character.GetCachedComponent<UltimateCharacterLocomotion>();
            for (int i = 0; i < m_IgnoreColliders.Length; ++i)
            {
                for (int j = 0; j < characterLocomotion.ColliderCount; ++j)
                {
                    Physics.IgnoreCollision(m_IgnoreColliders[i], characterLocomotion.Colliders[j], true);
                }
            }
            characterLocomotion.AddIgnoredColliders(m_IgnoreColliders);
            Debug.Log("Ignoring Colliders");
        }
        /// <summary>
        /// Triggers the OpenCloseDoor parameter. From Skycar
        /// </summary>
        private void OpenCloseDoor()
        {
            m_OpenedDoor = !m_OpenedDoor;
            m_Animator.SetTrigger(s_OpenCloseDoorParameter);
        }
        /// <summary>
        /// The character has entered the vehicle.
        /// </summary>
        /// <param name="character">The character that entered the vehicle.</param>
        public void EnteredVehicle(GameObject character)
        {
            m_CharacterAnimatorMonitor = character.GetCachedComponent<AnimatorMonitor>();  //Skycar code
            m_Character = character; //RCC Code

            EnableDisableVehicle(true); //RCC
        }
        /// <summary>
        /// Updates the animator. From Skycar
        /// Errors out if enabled on start and RCC must be enabled on start. Will figure later how to fix error
        /// </summary>
        public void Update()
        {
            m_Animator.SetFloat(m_HorizontalInputID, m_CharacterAnimatorMonitor.AbilityFloatData, 0, 0);
        }
        /// <summary>
        /// The character has started to exit the vehicle. Mostly RCC after removing EnableDisableCar
        /// </summary>
        /// <param name="character">The character that is exiting the vehicle.</param>
        public void ExitVehicle(GameObject character)
        {
            EnableDisableVehicle(false);
            m_Character = null;
        }
        /// <summary>
        /// The character has exited the vehicle.
        /// </summary>
        /// <param name="character">The character that exited the vehicle.</param>
        public void ExitedVehicle(GameObject character)
        {
            EventHandler.UnregisterEvent(character, "OnAnimatorOpenCloseDoor", OpenCloseDoor);  //Unregistering for Event
            //Mirrored in both RCC and Skycar
            var characterLocomotion = character.GetCachedComponent<UltimateCharacterLocomotion>();
            characterLocomotion.RemoveIgnoredColliders(m_IgnoreColliders);
            for (int i = 0; i < m_IgnoreColliders.Length; ++i)
            {
                for (int j = 0; j < characterLocomotion.ColliderCount; ++j)
                {
                    Physics.IgnoreCollision(m_IgnoreColliders[i], characterLocomotion.Colliders[j], false);
                }
            }
            //Skycar runs door close animation on vehicle
            if (m_OpenedDoor)
            {
                OpenCloseDoor();
            }
        }
    }
}

Any help would be appreciated. I'm willing to work with anyone to resolve this. Thanks
 
Have you compared your setup to the demo scene included with the integration?
 
I did, but your comment made me make a brand new scene and try this script. It almost works perfectly. I'm not sure what the problem with that scene is but I think a after few more tweeks and I can call this a good start for what I am attempting to do. I will post the finished script for others to try when it is done. thanks for the comment!
 
After looking at the problem it wasnt the scene it is actually the Nolan character used in the demo. When I use the Nolan character used in the RCC Integration scene it works. I was attempting to see what the problem could be. I am unable to find it. I took away all colliders, items, and FP Arms but still have the same issue. Another symptom is that the car bounces around like the hulk is bumping it with the Demo Nolan but not with the RCC one. Do you have any idea what could be causing this Justin?
 
Also when my character drives the car it jerks back and forth. I remember something with another problem where I had to move from update to fixed update. Do you know how I could change that here?
 
You do need to ensure the update location is set correctly for RCC. You can use the state system for that. If the demo character works it is likely something related to the ability order or the state.
 
I had the same thing. For me I just applied my changes to character prefab . And deleted in scene and dragged in a new one and it works. i have my character on Update at all times.
 
running into a couple issues with RCC in the included demo scene:

1. when Nolan makes contact with the car, he is sent flying (distance/speed varies). I've unticked some layers in Physics >> Layer Collision Matrix, which does stop the car from making awful collision noises, but the wonky physics remain (see gif below)
UCC_RCC-physics-2.gif

2. how can I increase car's area of entry for the player (i.e. the size of the region where the player is allowed to enter the vehicle)? I've tweaked the Size, Distance, and Angle variables in the Move Towards Location component, but they seem to have no impact; my character will not enter the car unless I am right up against the driver side door (which doesn't work super well, because touching the door triggers bug #1 outlined above). I am not using any animation to enter the car, just a teleport (Teleport Enter Exit is ticked on the Drive ability)
 
I just tried the demo scene and Nolan didn't go flying. If you place an output within CharacterLocomotion.ApplyMovement does the MoveDirection variable get really large?

2. how can I increase car's area of entry for the player (i.e. the size of the region where the player is allowed to enter the vehicle)? I've tweaked the Size, Distance, and Angle variables in the Move Towards Location component, but they seem to have no impact; my character will not enter the car unless I am right up against the driver side door (which doesn't work super well, because touching the door triggers bug #1 outlined above). I am not using any animation to enter the car, just a teleport (Teleport Enter Exit is ticked on the Drive ability)
Changing the detection variables within the Drive ability is the route. You could change the detection mode to trigger so the character doesn't need to be looking at the vehicle.
 
I just tried the demo scene and Nolan didn't go flying. If you place an output within CharacterLocomotion.ApplyMovement does the MoveDirection variable get really large?


Changing the detection variables within the Drive ability is the route. You could change the detection mode to trigger so the character doesn't need to be looking at the vehicle.

I'm not seeing ApplyMovement within CharacterLocomotion, not sure what I'm missing there (probably something simple, I'm an absolute beginner stumbling through these scripts and C#/OOP as a whole).

I did throw a Debug.Log(m_MoveDirection); into the CharacterLocomotion script and I did see a jump from in the Z coordinate from ~0.1 to double-digits when I "flew away" (see output below)

1650410419592.png

also, appreciate the insight regarding Drive ability - that did the trick.
 
just a quick follow-up: the "flying" doesn't occur every time you touch the car. it appears to be easiest to replicate around the doors of the car, and Nolan's movement speed has a direct impact on how far you potentially get launched (sprinting + jumping will produce a much more dramatic launch than just walking)

UCC_RCC-physics-3.gif

also, it appears other users have had this issue in the past: Link
 
Last edited:
Yeah I don't remember how I fixed that.. there's a ton of things that don't makes sense with this ability and it seems very complicated for something simple as get into a car. It should be hard coded so it can't be altered with i.e a override script that makes the character animate at go in position and always the same rotation...
Now with this ability and move towards it's super chaotic to get the character to just play the enter animation right and go in, he spins always different rotations and moves to different locations when entering car, the sitting position works , but sometimes he enters the car on the hood and moves then to sitting position... It makes no sense. And no it can't be replicated with the demo controller because it teleports and no animation..
 
That 32 value is the cause. I was able to reproduce it after your instructions - I'll let you know after I get a chance to debug the cause.
 
It looks like the cause is from some of the RCC physics materials that increase the bounce amount. You can fix this by either modifying the physic materials, or setting the Wall Bounce Modifier on the Ultimate Character Locomotion component to 0.
 
Top