here’s my code
‘’` {
[SerializeField]InputAction movement;
[SerializeField] float xSpeed = 20f;
[SerializeField] float ySpeed = 20f;
[SerializeField] float xRange = 10f;
[SerializeField] float yRange = 5f;
[SerializeField] float pitchFactor = -4.5f;
[SerializeField] float controlPitchFactor = -10f;
[SerializeField] float yawFactor = 3.5f;
[SerializeField] float rollFactor = 0f;
[SerializeField] InputAction fire;
float horizontalThrow;
float verticalThrow;
private void OnEnable()
{
movement.Enable();
fire.Enable();
}
private void OnDisable()
{
movement.Disable();
fire.Disable();
}
void Update()
{
ProccessTranslation();
ProccessRotaion();
}
private void ProccessRotaion()
{
float pitchByPosition = transform.localPosition.y * pitchFactor;
float pitchByVThrow = verticalThrow * controlPitchFactor;
float pitch = pitchByPosition + pitchByVThrow;
float yaw = transform.localPosition.x * yawFactor;
float roll = horizontalThrow * rollFactor;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}
private void ProccessTranslation()
{
horizontalThrow = movement.ReadValue<Vector2>().x;
// Debug.Log("Xthrow");
verticalThrow = movement.ReadValue<Vector2>().y;
// Debug.Log("Ythrow");
float xOffset = horizontalThrow * Time.deltaTime * xSpeed;
float newXPos = transform.localPosition.x + xOffset;
float limitXPos = Mathf.Clamp(newXPos, -xRange, +xRange);
float yOffset = verticalThrow * Time.deltaTime * ySpeed;
float newYPos = transform.localPosition.y + yOffset;
float limitYPos = Mathf.Clamp(newYPos, -yRange, +yRange);
transform.localPosition = new Vector3(limitXPos, limitYPos, transform.localPosition.z);
}
void ProccessFire()
{
if (fire.ReadValue<float>()> 0.5)
{
Debug.Log("shooting");
}
}
}```