Hi there, I was having the same trouble as some other questions on this lecture regarding the Waves not being able to be moved to the control timeline.
After I updated to Unity 2023.3.0b3 (beta) and 2022.3.17f1 (stable), that problem went away but after reimporting everything the ParticleSystem got messed up.
Explosions works just fine but the lasers from the player’s ship barely work, and after couple seconds it stops working.
I did notice there’s a field for “max particles”, but setting it to a high value doesn’t do much.
I’ll post my Player code for reference and screenshots of my particle system config.
Thanks!
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerControls : MonoBehaviour
{
[Header("General Setup Settings")]
[Tooltip("Uses the new input system to get the player's movement")]
[SerializeField] InputAction movementInput;
[Tooltip("Uses the new input system to get the player's fire command")]
[SerializeField] InputAction fireInput;
[Tooltip("How fast the ship moves up and down based upon player input")]
[SerializeField] float controlSpeed = 10f;
[Tooltip("How much can it move on the X axis")]
[SerializeField] float xRange = 10f;
[Tooltip("How much can it move on the Y axis")]
[SerializeField] float yRange = 10f;
[Header("Screen position based tuning")]
[Tooltip("How much should pitch based on the position")]
[SerializeField] float positionPitchFactor = -2f;
[Tooltip("How much should yaw based on the position")]
[SerializeField] float positionYawFactor = 2f;
[Header("Player position based tuning")]
[Tooltip("How much should pitch based on the control signal")]
[SerializeField] float controlPitchFactor = -10f;
[Tooltip("How much should roll based on the control signal")]
[SerializeField] float controlRollFactor = -20f;
[Tooltip("Smooth factor so ship inclination movement doesn't look janky")]
[SerializeField] float smoothInputSpeed = .1f;
[Header("Laser gun array")]
[Tooltip("Laser particle systems")]
[SerializeField] GameObject[] lasers;
Vector2 currentInputVector;
Vector2 smoothInputVelocity;
float horizontalThrow;
float verticalThrow;
private void OnEnable()
{
movementInput.Enable();
fireInput.Enable();
}
private void OnDisable()
{
movementInput.Disable();
fireInput.Disable();
}
void Update()
{
SmoothController();
ProcessTranslation();
ProcessRotation();
ProcessFiring();
}
private void ProcessFiring()
{
var fireAmount = fireInput.ReadValue<float>();
if (fireAmount > 0.5f)
{
ToggleLasers(true);
} else
{
ToggleLasers(false);
}
}
private void ToggleLasers(bool isActive)
{
foreach (var laser in lasers)
{
var emissionModule = laser.GetComponent<ParticleSystem>().emission;
emissionModule.enabled = isActive;
}
}
private void SmoothController()
{
Vector2 targetVector = movementInput.ReadValue<Vector2>();
currentInputVector = Vector2.SmoothDamp(currentInputVector, targetVector, ref smoothInputVelocity, smoothInputSpeed);
horizontalThrow = currentInputVector.x;
verticalThrow = currentInputVector.y;
}
private void ProcessRotation()
{
float pitchDueToPosition = transform.localPosition.y * positionPitchFactor;
float pitchDueToControlThrow = verticalThrow * controlPitchFactor;
float pitch = pitchDueToPosition + pitchDueToControlThrow;
float yaw = transform.localPosition.x * positionYawFactor;
float roll = horizontalThrow * controlRollFactor;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}
private void ProcessTranslation()
{
float xOffset = transform.localPosition.x + horizontalThrow * Time.deltaTime * controlSpeed;
float yOffset = transform.localPosition.y + verticalThrow * Time.deltaTime * controlSpeed;
float clampledXPos = Mathf.Clamp(xOffset, -xRange, xRange);
float clampledYPos = Mathf.Clamp(yOffset, -yRange, yRange);
transform.localPosition = new Vector3(
clampledXPos,
clampledYPos,
transform.localPosition.z);
}
}
![Screenshot 2024-01-21 104957|280x500](upload://cqQLH4FHMBNlEt4gArohUspD3Qi.png)
![Screenshot 2024-01-21 105028|268x500](upload://fkeZrKbIlvS45gv4QJrVmK9GMdh.png)
![Screenshot 2024-01-21 105036|432x248](upload://lVoALBieNwCGyeVi0796XnTFYlS.png)
![Screenshot 2024-01-21 105040|437x338](upload://641BZKJ8V7w94Lh7E9kIqZvYzvJ.png)