In Reality Composer Pro there is a flag to toggle the loop of the particle system. In code I couldn't find a .loop value on the ParticleEmitterComponent - does anyone know how else I can disable the looping there?
How to disable loop for ParticleEmitterComponent on visionOS?
297 Views Asked by Mitemmetim At
2
There are 2 best solutions below
0
On
Besides the .once(...) case of the timing enum, you can use the fantastic burst() instance method which emits burstCount particles on the next update call. Here's the code:
import SwiftUI
import RealityKit
struct ContentView : View {
@State var particles = ParticleEmitterComponent()
let entity = Entity()
var body: some View {
VStack {
Button("Burst") {
particles.isEmitting = false // important
entity.components.remove(ParticleEmitterComponent.self)
entity.components[ParticleEmitterComponent.self] = pSystem()
}
RealityView { content in
content.add(entity)
}
}
}
func pSystem() -> ParticleEmitterComponent {
particles.emitterShape = .sphere
particles.burstCount = 1500
particles.burst()
return particles
}
}

To disable the loop you have to set the
.timingvalue to once like this: