hello there my lasers arent working when i press control(im on mac) i checked the input manager Fire1 is set to control. heres my script i can send more information if needed
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputController : MonoBehaviour
{
[SerializeField] InputAction movement;
[SerializeField] InputAction fire;
[SerializeField] float speed = 10f;
[SerializeField] float xRange = 5.9f;
[SerializeField] float yRange = 4.8f;
[SerializeField] GameObject lasers;
[SerializeField] float positionPichFactor = -2f;
[SerializeField] float controlPichFactor = -10f;
[SerializeField] float positionYawFactor = -10;
[SerializeField] float controlRollFactor = -3;
float yThrow;
float xThrow;
// Start is called before the first frame update
void Start()
{
}
private void OnEnable()
{
movement.Enable();
fire.Enable();
}
private void OnDisable()
{
movement.Disable();
fire.Disable();
}
void Update()
{
ProcessTranslation();
ProcessRotation();
ProcessFiring();
}
void ProcessRotation()
{
float PitchDueToPosition = transform.localPosition.y * positionPichFactor;
float PitchDueToControlThrow = yThrow * controlPichFactor;
float pitch = PitchDueToPosition + PitchDueToControlThrow;
float yaw = transform.localPosition.x * positionYawFactor;
float roll = xThrow * controlRollFactor;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}
private void ProcessTranslation()
{
xThrow = movement.ReadValue<Vector2>().x;
yThrow = movement.ReadValue<Vector2>().y;
Debug.Log(xThrow);
Debug.Log(yThrow);
float xOffset = xThrow * Time.deltaTime * speed;
float rawXPos = transform.localPosition.x + xOffset;
float clampedXPos = Mathf.Clamp(rawXPos, -xRange, xRange);
float yOffset = yThrow * Time.deltaTime * speed;
float rawYPos = transform.localPosition.y + yOffset;
float clampedYPos = Mathf.Clamp(rawYPos, -yRange, yRange);
transform.localPosition = new Vector3(clampedXPos, clampedYPos, transform.localPosition.z);
}
void ProcessFiring()
{
if (fire.ReadValue<float>() > 0.0)
{
ActivateLasers();
Debug.Log("FIRING..123");
}
else
{
DeactivateLasers();
}
}
private void ActivateLasers()
{
foreach (GameObject TheLaser in lasers)
{
TheLaser.SetActive(true);
}
}
private void DeactivateLasers()
{
foreach (GameObject TheLaser in lasers)
{
TheLaser.SetActive(false);
}
}
}