JacobDSiler
Member
Hi all,
I have been working on this piloting ability, which will allow my character to pilot generic crafts.
I just want to start simple and have my character jump in front of the pilot spot, and be able to steer it. Here's what I have so far.
It isn't working, but I can't determine why.
The messages just come one after the other
I'm sure I've overlooked something silly here, but any ideas of what it is, would be very much appreciated.
Thanks!
I have been working on this piloting ability, which will allow my character to pilot generic crafts.
I just want to start simple and have my character jump in front of the pilot spot, and be able to steer it. Here's what I have so far.
C#:
using UnityEngine;
using Opsive.UltimateCharacterController.Character.Abilities;
using Opsive.UltimateCharacterController.Character;
[DefaultAllowPositionalInput(false)]
[DefaultAllowRotationalInput(false)]
public class Pilot : DetectObjectAbilityBase
{
[Tooltip("A reference to the Ultimate Character Controller character.")]
[SerializeField] private GameObject m_Character;
[SerializeField] private Transform pilotSpot;
//Vessel control variables.
private float steerage;
private float steerageRatio=1f;
protected override void AbilityStarted()
{
base.AbilityStarted();
m_Character.transform.parent = pilotSpot;
//m_Character.transform.parent = pilotSpot;
SetToPilotSpot();
Debug.Log("Starting to pilot.");
}
private void SetToPilotSpot()
{
var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();
if (characterLocomotion != null)
{
characterLocomotion.SetPositionAndRotation(pilotSpot.position, pilotSpot.transform.rotation);
}
}
public override void Update()
{
base.Update();
//Take input from the steering wheel.
steerage = Input.GetAxis("Horizontal");
Debug.Log(steerage*steerageRatio);
}
protected override void AbilityStopped(bool force)
{
base.AbilityStopped(force);
Debug.Log("Piloting finished.");
}
/// <summary>
/// The character has exited a trigger.
/// </summary>
/// <param name="other">The trigger collider that the character exited.</param>
public override void OnTriggerExit(Collider other)
{
// The detected object will be set when the ability starts and contains a reference to the object that allowed the ability to start.
if (other.gameObject == m_DetectedObject)
{
StopAbility();
}
base.OnTriggerExit(other);
}
}
It isn't working, but I can't determine why.
The messages just come one after the other
Piloting started
and then Piloting finished
I'm sure I've overlooked something silly here, but any ideas of what it is, would be very much appreciated.
Thanks!