svetagrom555-gmail-com/novosibirskii-troleibus-3d
using UnityEngine; using System.Collections.Generic; public class TrolleybusController : MonoBehaviour { [Header("Настройки движения")] public float speed = 10f; // Скорость движения (м/с) public float stopDuration = 5f; // Время стоянки на остановке (сек) public List<Transform> waypoints; // Точки маршрута public bool loopRoute = true; // Зацикливать маршрут? [Header("Визуальные эффекты")] public Light headlight; // Фара (опционально) public ParticleSystem smokeEffect; // Дым из-под колёс (опционально) private int currentWaypointIndex = 0; private bool isStopped = false; private float stopTimer = 0f; void Start() { if (waypoints.Count == 0) { Debug.LogError("Нет точек маршрута! Добавьте Waypoint в список."); enabled = false; } else { transform.position = waypoints[0].position; } } void Update() { if (isStopped) { stopTimer += Time.deltaTime; if (stopTimer >= stopDuration) { isStopped = false; stopTimer = 0f; } return; } // Движение к следующей точке Transform target = waypoints[currentWaypointIndex]; Vector3 direction = target.position - transform.position; float distanceToTarget = direction.magnitude; if (distanceToTarget < 1f) // Приблизились к точке { isStopped = true; currentWaypointIndex++; if (currentWaypointIndex >= waypoints.Count) { if (loopRoute) { currentWaypointIndex = 0; } else { enabled = false; // Остановка в конце маршрута } } } else { // Двигаемся вперёд Vector3 moveDirection = direction.normalized; transform.position += moveDirection * speed * Time.deltaTime; // Поворачиваем троллейбус в направлении движения transform.forward = moveDirection; } } // Визуальные эффекты (опционально) void OnTriggerEnter(Collider other) { if (other.CompareTag("Waypoint")) { if (headlight != null) headlight.enabled = true; if (smokeEffect != null) smokeEffect.Play(); } } void OnTriggerExit(Collider other) { if (other.CompareTag("Waypoint")) { if (headlight != null) headlight.enabled = false; if (smokeEffect != null) smokeEffect.Stop(); } } }
язык не указан · рейтинг — · 👍 0 · ❤️ 0 · 💎 0 · 0 форков · ссылка на SourceCraft
Дата анализа: 29.09.2026 00:58
Почему такой балл
Сильные и слабые стороны
Слабые: Документация: нет данных, CI/CD: нет данных, Безопасность: нет данных, Активность: нет данных, Issues: нет данных, Состояние кода: нет данных
Находки и рекомендации
Находок нет — либо скан ещё не считал Score, либо проблем не найдено.
История проверок
- 29.09.2026 00:58 — нет данных