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.
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();
}
}
}