please help using drive ability

Ozymandiaz

New member
i try to make car with other car model instead skycar.

i'm using edy's vehicle physics and synty studio's polygon heist assets in third person controller top-down camera, character.

and i made my car by replacing the asset based on skycar.

i also wrote vehicle script for my car based on skycar.cs

but i have some problems.

first, when i use action key near by car, character move toward to ability start location, but sometimes not execute drive ability immediate. it seems move toward ability is too long activity.

second, when i using vehicle if i press jump key (Space Bar), character have exit from the car. not using action key(F)

third, if i adjust driverlocation transform in playmode for my car's correctly seat location, character popout from the car.

those three problems are not cause in demo scene.

am i missing something?

or can i use drive ability for teleport near by car not using abilitystartlocation for no separated door car model?

best regards.

C#:
using Opsive.Shared.Events;
using Opsive.Shared.Game;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
using UnityEngine;
using EVP;

public class MyVehicle : MonoBehaviour, IDriveSource
{
    [SerializeField] protected Transform m_DriverLocation;
    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 VehicleStandardInput m_UserControl;
    private AnimatorMonitor m_CharacterAnimatorMonitor;
    private int m_HorizontalInputID;
    private bool m_OpenedDoor;

    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 Awake()
    {
        m_GameObject = gameObject;
        m_Transform = transform;
        //m_Animator = GetComponent<Animator>(); // my car doesn't have animator. because door is not separate mesh.
        m_Rigidbody = GetComponent<Rigidbody>();
        m_UserControl = GetComponent<VehicleStandardInput>();
        m_HorizontalInputID = Animator.StringToHash("HorizontalInput");
        EnableDisableCar(false);
    }

    /// <summary>
    /// Enables or disables the car components.
    /// </summary>
    /// <param name="enable">Should the car be enabled?</param>
    private void EnableDisableCar(bool enable)
    {
        enabled = m_UserControl.enabled = enable;
        //m_Rigidbody.isKinematic = !enable; // i want vehicle's rigidbody always activate.
    }

    /// <summary>
    /// The character has started to enter the vehicle.
    /// </summary>
    /// <param name="character">The character that is entering the vehicle.</param>
    public void EnterVehicle(GameObject character)
    {
        EventHandler.RegisterEvent(character, "OnAnimatorOpenCloseDoor", OpenCloseDoor);
    }

    /// <summary>
    /// Triggers the OpenCloseDoor parameter.
    /// </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>();
        EnableDisableCar(true);
    }

    /// <summary>
    /// Updates the animator.
    /// </summary>
    public void Update()
    {
        //m_Animator.SetFloat(m_HorizontalInputID, m_CharacterAnimatorMonitor.AbilityFloatData, 0, 0);
    }

    /// <summary>
    /// The character has started to exit the vehicle.
    /// </summary>
    /// <param name="character">The character that is exiting the vehicle.</param>
    public void ExitVehicle(GameObject character)
    {
        EnableDisableCar(false);
    }

    /// <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);

        if (m_OpenedDoor)
        {
            OpenCloseDoor();
        }
    }
}

config1.jpg

config2.jpg
 
first, when i use action key near by car, character move toward to ability start location, but sometimes not execute drive ability immediate. it seems move toward ability is too long activity.
On the Ability Start Location you can adjust the threshold for when the ability starts. https://opsive.com/support/document...r/character/abilities/ability-start-location/

second, when i using vehicle if i press jump key (Space Bar), character have exit from the car. not using action key(F)
You can change the Input Name using the state system when the drive ability is active.

third, if i adjust driverlocation transform in playmode for my car's correctly seat location, character popout from the car.
Can you reproduce it within the demo scene? I just moved the drive location during play mode and the character didn't pop.


or can i use drive ability for teleport near by car not using abilitystartlocation for no separated door car model?
Yes, you can remove the ability start location and enable teleport on the drive ability.
 
Can you reproduce it within the demo scene? I just moved the drive location during play mode and the character didn't pop.

yes i reproduce within the demo scene.

when i adjust DriverLocation position after follow step below, character are popout from the car

0. open demo scene.
1. delete original nolan character
2. create character from character manager wizard.
3. add drive ability, set object id to 14.
4. add Drive State(DriveUltimateCharacterLocomotionPreset) to UltimateCharacterLocomotion.cs component.
5. add Drive State(DriveCharacterIKPreset) to CharacterIK.cs component.
6. set new character to DemoManager.
7. go to play mode and adjust DriverLocation

i try to other character model and also tested nolan model, but popout situation cames out.

i'm using 2019.2.6f1.

best regards.
 
I just tried that and everything worked without a problem. When I moved the drive location outside of the car the character continued to be in the driving animation but was outside the car, which is expected.
 
please see this video, 0:00 ~ 1:27 is original demo scene not modified.
after 1:27 is tested by create new character.

 
Hmm, one way to figure out the cause is to place a breakpoint within Drive.AbilityStopped. What is the callstack which is causing that ability to stop?
 
Hmm, one way to figure out the cause is to place a breakpoint within Drive.AbilityStopped. What is the callstack which is causing that ability to stop?

i'm just tested with breakpoint on Drive.AbilityStopped.

and i found that the fall ability to stops the drive ability.

when moving the drive ability front in order than fall ability in UltimateCharacterLocomotion.cs component's Abilities section, it does not cause problems.

and also, i adjust the order front rather than jump ability, the character popout situation not occurred when press the jump key.

thanks for the advise

best regards.
 
Yes, you can see one here:

 
In my opinion the guide is lacking some steps to get the Drive ability working. I spent like an hour or two trying to figure what I was missing. I was comparing my character and the Nolan character to see what the differences was. I have created a document of the extra things that you will need to add to your character. I believe I have touched on all the required points. If anyone has found something that I'm missing please let me know so that I can update the document.

Important Notes for Drive Ability
 
@Justin I have enabled the "Teleport Enter Exit" option but my character is still moving around the vehicle to enter. Though the character is not playing the animations. Is it possible to just teleport the character into the vehicle without having to move the character around?
 
I have copy/pasted the SkyCar from the demo scene into my blank scene. I have just a 3D plane as the ground for the player and vehicle. Is there any reason why the SkyCar have a jittery motion? Like it's jerking forwards and backwards quickly. The actual movement of the car seems to be fine. It doesn't happen in the demo scene. I have also copy/pasted Nolan into the scene and it does the same thing.
 
In my opinion the guide is lacking some steps to get the Drive ability working. I spent like an hour or two trying to figure what I was missing. I was comparing my character and the Nolan character to see what the differences was. I have created a document of the extra things that you will need to add to your character. I believe I have touched on all the required points. If anyone has found something that I'm missing please let me know so that I can update the document.

Important Notes for Drive Ability
Thanks for those notes, I'll see how I can improve the docs with them.

Is it possible to just teleport the character into the vehicle without having to move the character around?
Right now it doesn't teleport until the character is in position. You're right that this doesn't make much sense so I'll see if there's anything that I can do to improve it.

I have copy/pasted the SkyCar from the demo scene into my blank scene. I have just a 3D plane as the ground for the player and vehicle. Is there any reason why the SkyCar have a jittery motion? Like it's jerking forwards and backwards quickly. The actual movement of the car seems to be fine. It doesn't happen in the demo scene. I have also copy/pasted Nolan into the scene and it does the same thing.
This sounds like the update rate is different between the controller and car. The car updates within the Update loop so make sure that is set within the Ultimate Character Locomotion component.
 
I did change the Update Location in Ultimate Character Locomotion to "Update". Where is that option for the vehicle?
 
@Ozymandiaz did you ever get the Edy's Vehicle Physics working correctly with version 2.2?

yes, my tested environment is below:

Unity: 2019.3.10f1
Third Person Controller: 2.2
Edy's Vehicle Physics: 5.3

and so do i. even if the teleport option is on, there is a phenomenon in which the character does not immediately get in the car and tries to get to the ability starting point.

i've analyze drive ability, and it seems to be driving ability use move towards ability and must have ability start location.

if ability start location is overlapped with another collider, it seems to be trying to find an appropriate starting position because there is no valid entry/exit point.

if you want the character to teleport, near by vehicle without entering/exiting animations, i think you will need to write new script.

best regards
 
I got the Drive ability working I now need the ability to switch controls over to Edy's Vehicle Physics. Is your script working for that?
 
I got the Drive ability working I now need the ability to switch controls over to Edy's Vehicle Physics. Is your script working for that?

i use VehicleStandardInput in edy's vehicle physics.

my car script are just set VehicleStandardInput's enable state change in OnEnterVehicle and OnExitVehicle inherite by IDriveSource.
 
This sounds like the update rate is different between the controller and car. The car updates within the Update loop so make sure that is set within the Ultimate Character Locomotion component.

@Justin I have made sure the Update Location is Update but I'm still getting the jittery motion.

1.PNG
 
I have came across a issue where the player's weapon will not unequip when they press F to enter the vehicle. So the character enters the vehicle with the weapon equipped.
 
Top