public void PlayerInputs(
float a_Vertical,
float a_Horizontal,
float a_camVertical,
float a_camHorizontal,
float a_triggers,
bool a_bumperLeft,
bool a_bumperRight,
bool a_faceUp, // Y - Open hatch
bool a_faceDown, // A - Fire cannon forwards
bool a_faceLeft, // X - Fire broadside left
bool a_faceRight, // B - Fire broadside right
float a_dPadHorizontal,
float a_dPadVertical)
{
//previousYaw = yaw;
//previousPitch = pitch;
//previousRoll = roll;
//previousThrottle = throttle;
// Zero input if not enabled
if (!this.isActiveAndEnabled)
{
pitch = 0;
yaw = 0;
roll = 0;
throttle = 0;
openHatch = false;
}
else
{
// Use this to convert buttonpresses to axis input;
/*float rollFloat = 0;
if (a_faceLeft)
{
rollFloat = -1;
}
else if (a_faceRight)
{
rollFloat = 1;
}*/
//roll = 0.25f * a_Horizontal + rollFloat;
pitch = a_Vertical;// +a_camVertical;
yaw = a_Horizontal;
//roll = a_camHorizontal;
throttle = a_triggers;
// Reverse yaw if play is moving backwards
if (a_triggers < 0)
{
// Ensure player is actually moving backwards
if (Vector3.Dot(m_myRigid.velocity, m_trans.forward) < 0)
{
m_isReversing = true;
}
}
else
{
// Player is moving forwards, or reverse trigger not held
m_isReversing = false;
}
// If about to open hatch
//if (!openHatch && a_faceUp)
//if (!openHatch && a_dPadVertical < 0)
//if (!openHatch)
if (openHatch) // is this the best solution?
{
Invoke("TrapdoorRumblePulse", trapdoorRumbleCooldown);
}
// Check buttonPresses
// openHatch = a_faceUp;//(a_faceUp || a_faceDown);
//if (a_dPadVertical < 0)
if (a_bumperLeft || a_bumperRight || (a_dPadVertical < 0))
{
openHatch = true;
}
else
{
openHatch = false;
}
// If in auto-open zone, force open
if (forceOpenHatch)
{
openHatch = forceOpenHatch;
}
// Keep the inputs in reasonable ranges, see the standard asset examples for more
ClampInputs();
/*
// Open/close the hatches
m_anim.SetBool(m_animHatchOpen, a_faceUp);
m_anim.SetBool(m_animTrapdoorOpen, a_faceUp);
*/
// Spin the propeller
float animThrottle = throttle * 2.0f; // [-1, 1] to [-2, 2], 50% now maps to 100% anim throttle
float animThrottleSign = animThrottle >= 0 ? 1 : -1;
animThrottle = Mathf.Abs(animThrottle);
if (animThrottle > 1)
{
// Scale up to the animation throttle multiplier
float boundedThrottle = animThrottle * 0.5f + 0.5f;
animThrottle = boundedThrottle * (animThrottleMult - 1) + 1;
}
m_anim.SetFloat(m_animPropellerMult, animThrottleSign * animThrottle);
Vibrate();
}
}