void FixedUpdate() { if ( entity.Equals(Entity.Null) || !entityManager.HasComponent <NavAgent>(entity) || !entityManager.HasComponent <Parent>(entity) || !entityManager.HasComponent <Translation>(entity) || !entityManager.HasComponent <Rotation>(entity) ) { return; } var agent = entityManager.GetComponentData <NavAgent>(entity); agent.JumpDegrees = JumpDegrees; agent.JumpGravity = JumpGravity; agent.JumpSpeedMultiplierX = JumpSpeedMultiplierX; agent.JumpSpeedMultiplierY = JumpSpeedMultiplierY; agent.TranslationSpeed = TranslationSpeed; agent.RotationSpeed = RotationSpeed; agent.TypeID = NavUtil.GetAgentType(Type); agent.Offset = Offset; entityManager.SetComponentData(entity, agent); if (!lastWorldDestination.Equals(WorldDestination)) { entityManager.AddComponentData <NavNeedsDestination>(entity, new NavNeedsDestination { Destination = WorldDestination, Teleport = Teleport }); lastWorldDestination = WorldDestination; InitializeEntityTransform(); // Reinitialize in case GameObject transform changes in-between pathing. } var surfaceEntity = entityManager.GetComponentData <Parent>(entity); if (surfaceEntity.Value.Equals(Entity.Null) || !entityManager.HasComponent <NavSurface>(surfaceEntity.Value)) { return; } surfaceSystem.GameObjectMapTryGetValue( entityManager.GetComponentData <NavSurface>(surfaceEntity.Value).TransformInstanceID, out var surfaceGameObject ); if (surfaceGameObject == null) { return; } gameObject.transform.SetParent(surfaceGameObject.transform); gameObject.transform.localPosition = entityManager.GetComponentData <Translation>(entity).Value / surfaceGameObject.transform.localScale; gameObject.transform.localRotation = entityManager.GetComponentData <Rotation>(entity).Value; }
void Start() { Entity = entityManager.CreateEntity(); entityManager.AddComponentData(Entity, new NavAgent { JumpDegrees = JumpDegrees, JumpGravity = JumpGravity, JumpSpeedMultiplierX = JumpSpeedMultiplierX, JumpSpeedMultiplierY = JumpSpeedMultiplierY, TranslationSpeed = TranslationSpeed, RotationSpeed = RotationSpeed, TypeID = NavUtil.GetAgentType(Type), Offset = Offset }); InitializeEntityTransform(); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { dstManager.AddComponentData(entity, new NavAgent { JumpDegrees = jumpDegrees, JumpGravity = jumpGravity, JumpSpeedMultiplierX = jumpSpeedMultiplierX, JumpSpeedMultiplierY = jumpSpeedMultiplierY, TranslationSpeed = translationSpeed, RotationSpeed = rotationSpeed, TypeID = NavUtil.GetAgentType(type), Offset = offset }); dstManager.AddComponent <NavNeedsSurface>(entity); dstManager.AddComponent <NavFixTranslation>(entity); if (isTerrainCapable) { dstManager.AddComponent <NavTerrainCapable>(entity); } }