void Start() { var prefabEntity = entityManager.CreateEntityQuery(typeof(NavAgentPrefab)).GetSingleton <NavAgentPrefab>().Value; SpawnSystem.Enqueue(new Spawn() .WithPrefab(prefabEntity) .WithComponentList( new NavAgent { JumpDegrees = 45, JumpGravity = 100, JumpSpeedMultiplierX = 1.5f, JumpSpeedMultiplierY = 2, TranslationSpeed = 20, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }, new NavNeedsSurface { }, new Parent { }, new LocalToParent { }, new Translation { Value = new float3(0, 1, 0) } ), 50 ); }
void Spawn() { var outputEntities = new NativeArray <Entity>(spawnCount, Allocator.Temp); entityManager.Instantiate(currentPrefab, outputEntities); for (var i = 0; i < outputEntities.Length; ++i) { entityManager.AddComponentData(outputEntities[i], new NavAgent { TranslationSpeed = 20, RotationSpeed = 0.3f, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData <LocalToWorld>(outputEntities[i], new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }); entityManager.AddComponent <Parent>(outputEntities[i]); entityManager.AddComponent <LocalToParent>(outputEntities[i]); entityManager.AddComponent <NavNeedsSurface>(outputEntities[i]); } outputEntities.Dispose(); }
void Start() { var prefabEntity = entityManager.CreateEntityQuery(typeof(DinosaurPrefab)).GetSingleton <DinosaurPrefab>().Value; SpawnSystem.Enqueue(new Spawn() .WithPrefab(prefabEntity) .WithComponentList( new NavAgent { JumpDegrees = 45, JumpGravity = 100, JumpSpeedMultiplierX = 2, JumpSpeedMultiplierY = 4, TranslationSpeed = 40, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }, new Parent { }, new LocalToParent { }, new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }, new NavNeedsSurface { } ) ); }
void Enqueue() { var entities = new NativeArray <Entity>(enqueueCount, Allocator.Temp); entityManager.Instantiate(currentPrefab, entities); for (var i = 0; i < entities.Length; ++i) { entityManager.AddComponentData(entities[i], new NavAgent { TranslationSpeed = 20, RotationSpeed = 0.3f, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData(entities[i], new Translation { Value = SpawnOffset }); entityManager.AddComponent <LocalToWorld>(entities[i]); entityManager.AddComponent <Parent>(entities[i]); entityManager.AddComponent <LocalToParent>(entities[i]); entityManager.AddComponent <NavNeedsSurface>(entities[i]); entityManager.AddComponent <NavTerrainCapable>(entities[i]); } entities.Dispose(); }
void Start() { var prefabEntity = entityManager.CreateEntityQuery(typeof(DinosaurPrefab)).GetSingleton <DinosaurPrefab>().Value; var entity = entityManager.Instantiate(prefabEntity); entityManager.AddComponentData(entity, new NavAgent { JumpDegrees = 45, JumpGravity = 100, JumpSpeedMultiplierX = 2, JumpSpeedMultiplierY = 4, TranslationSpeed = 40, RotationSpeed = 0.3f, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData <LocalToWorld>(entity, new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }); entityManager.AddComponent <Parent>(entity); entityManager.AddComponent <LocalToParent>(entity); entityManager.AddComponent <NavNeedsSurface>(entity); }
void Enqueue() { SpawnSystem.Enqueue(new Spawn() .WithPrefab(currentPrefab) .WithComponentList( new NavAgent { JumpDegrees = 45, JumpGravity = 200, TranslationSpeed = 20, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }, new Parent { }, new LocalToParent { }, new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }, new NavNeedsSurface { } ), enqueueCount ); }
void Enqueue() { if (!IsForAgents) { var random = new Unity.Mathematics.Random((uint)new System.Random().Next()); for (int i = 0; i < enqueueCount; ++i) { SpawnSystem.Enqueue(new Spawn() .WithPrefab(prefabEntity) .WithComponentList( new Translation { Value = new float3( random.NextInt(-25, 25), 2, random.NextInt(-25, 25) ) } ) ); } return; } SpawnSystem.Enqueue(new Spawn() .WithPrefab(prefabEntity) .WithComponentList( new NavAgent { JumpDegrees = 45, JumpGravity = 200, TranslationSpeed = 20, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }, new NavNeedsSurface { }, new Parent { }, new LocalToParent { }, new Translation { Value = new float3(0, 1, 0) } ), enqueueCount ); }
void Spawn() { var outputEntities = new NativeArray <Entity>(spawnCount, Allocator.Temp); entityManager.Instantiate(currentPrefab, outputEntities); for (var i = 0; i < outputEntities.Length; ++i) { entityManager.AddComponentData(outputEntities[i], new NavAgent { TranslationSpeed = 20, ObstacleAversionDistance = 4f, AgentAversionDistance = 3f, SeparationPerceptionRadius = 1f, AlignmentPerceptionRadius = currentPrefab.Equals(cylinderPrefab) ? 1f : 3f, CohesionPerceptionRadius = currentPrefab.Equals(cylinderPrefab) ? 1f : 3f, RotationSpeed = 0.3f, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData <LocalToWorld>(outputEntities[i], new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }); entityManager.AddComponent <Parent>(outputEntities[i]); entityManager.AddComponent <LocalToParent>(outputEntities[i]); entityManager.AddComponent <NavNeedsSurface>(outputEntities[i]); entityManager.AddComponent <NavFlocking>(outputEntities[i]); entityManager.AddComponent <NavObstacleSteering>(outputEntities[i]); } outputEntities.Dispose(); }
void Start() { var entities = new NativeArray <Entity>(50, Allocator.Temp); var prefab = entityManager.GetPrefab <Dinosaur>(); entityManager.Instantiate(prefab, entities); for (var i = 0; i < entities.Length; ++i) { entityManager.AddComponentData(entities[i], new NavAgent { JumpDegrees = 45, JumpGravity = 100, JumpSpeedMultiplierX = 1.5f, JumpSpeedMultiplierY = 2, TranslationSpeed = 20, RotationSpeed = 0.3f, TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData <LocalToWorld>(entities[i], new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }); entityManager.AddComponent <Parent>(entities[i]); entityManager.AddComponent <LocalToParent>(entities[i]); entityManager.AddComponent <NavNeedsSurface>(entities[i]); } entities.Dispose(); }
void Spawn() { var entities = new NativeArray <Entity>(spawnCount, Allocator.Temp); entityManager.Instantiate(currentPrefab, entities); for (var i = 0; i < entities.Length; ++i) { entityManager.AddComponentData(entities[i], new PathAgent { TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID), Offset = new float3(0, 1, 0) }); entityManager.AddComponentData(entities[i], new LocalToWorld { Value = float4x4.TRS( new float3(0, 1, 0), quaternion.identity, 1 ) }); entityManager.AddComponentData(entities[i], new PathFlocking { ObstacleAversionDistance = 4f, AgentAversionDistance = 3f, SeparationPerceptionRadius = 1f, AlignmentPerceptionRadius = currentPrefab.Equals(cylinderPrefab) ? 1f : 3f, CohesionPerceptionRadius = currentPrefab.Equals(cylinderPrefab) ? 1f : 3f, }); entityManager.AddComponent <PathSteering>(entities[i]); } entities.Dispose(); }