Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/CharacterControllerSpawnDeformation.cs
2026-03-04 09:37:33 +08:00

32 lines
982 B
C#

using UnityEngine;
public class CharacterControllerSpawnDeformation : MonoBehaviour
{
public static float TimeBtwnEachDeformation = 0.025f;
public CharacterController controller;
public PlayerMovement playerMovement;
private float lastDeformationSpawnedTime;
private void Update()
{
if (IsControllerMoving() && Time.realtimeSinceStartup - lastDeformationSpawnedTime >= TimeBtwnEachDeformation && PoolManager.Instances[PoolManager.InstanceType.Deformer] != null)
{
GameObject nextAvailable = PoolManager.Instances[PoolManager.InstanceType.Deformer].getNextAvailable();
if (nextAvailable != null)
{
lastDeformationSpawnedTime = Time.realtimeSinceStartup;
nextAvailable.transform.position = base.transform.position + playerMovement.modelTransform.forward * Vector3.Normalize(controller.velocity).magnitude;
nextAvailable.SetActive(value: true);
}
}
}
private bool IsControllerMoving()
{
return controller.velocity.sqrMagnitude > 0f;
}
}