Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void EffectSpawnerComponent::SpawnEffect(AZ::Vector3 pos, AZ::Vector3 hit_normal, EffectToSpawn effect)
- {
- AZStd::shared_ptr<AZ::Entity> entity = AZStd::make_shared<AZ::Entity>("SpawnedEffect");
- // Before entity activation create all necessary components
- AzFramework::TransformComponent* transform = azdynamic_cast<AzFramework::TransformComponent*>(entity->CreateComponent(AZ::TransformComponentTypeId));
- if (transform)
- {
- AZ::Vector3 pos = m_entity->GetTransform()->GetWorldTranslation();
- AZ::TransformConfig conf;
- conf.m_isStatic = false;
- conf.m_worldTransform = AZ::Transform::CreateTranslation(pos);
- conf.m_netSyncEnabled = false;
- conf.m_parentId = m_entity->GetId();
- conf.m_parentActivationTransformMode = AZ::TransformConfig::ParentActivationTransformMode::MaintainOriginalRelativeTransform;
- conf.m_interpolatePosition = AZ::InterpolationMode::NoInterpolation;
- conf.m_interpolatePosition = AZ::InterpolationMode::NoInterpolation;
- transform->SetConfiguration(conf);
- }
- LmbrCentral::ParticleComponent* emit = azdynamic_cast<LmbrCentral::ParticleComponent*>(entity->CreateComponent(AZ::AzTypeInfo<LmbrCentral::ParticleComponent>::Uuid()));
- if (emit)
- {
- using namespace LmbrCentral;
- AZStd::string name = "MyParticles.DroidHit";
- LmbrCentral::ParticleEmitterSettings emitterSettings;
- emitterSettings.m_targetEntity = entity->GetId();
- emitterSettings.m_notAttached = false;
- emitterSettings.m_visible = true;
- ParticleComponentRequestBus::Event(entity->GetId(), &ParticleComponentRequestBus::Events::SetupEmitter, name, emitterSettings);
- ParticleComponentRequestBus::Event(entity->GetId(), &ParticleComponentRequestBus::Events::Show);
- emit->Init();
- emit->Activate();
- }
- // We can't add component while the entity is active, so activate it after adding components!
- entity->Init();
- entity->Activate();
- // Owner Entity(parent entity) subscribs for the child's EntityBus events (activate/deactivate)
- //AZ::EntityBus::MultiHandler::BusConnect(entity->GetId());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement