Answer the question
In order to leave comments, you need to log in
How to get a component from an object? (LeoEcs + UniLeo)?
Hello!
I recently started learning Ecs and made this factory:
public class StreetHeroesFactory : IEcsInitSystem
{
private readonly List<Hero> _playerHeroes;
private readonly MovePoint[] _spawnPoints;
public void Init()
{
foreach (var hero in _playerHeroes)
{
var randomPoint = GetRandomSpawnPoint();
var heroObject = Object.Instantiate(hero.MoveHeroObject, randomPoint.Transform.position, Quaternion.identity);
}
}
public MovePoint GetRandomSpawnPoint() =>
_spawnPoints[Random.Range(0, _spawnPoints.Length)];
}
[Serializable]
public struct MovingHeroComponent
{
public float StayTime;
[HideInInspector] public Transform[] MovePoints; // вот точки
}
public class MoveHeroComponentProvider : MonoProvider<MovingHeroComponent>
{
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question