UnitStunVfx.cs

A component that applies a spinning stun particle effect. It stores a ParticleEffect property, picks a random rotation speed and direction on awake, and rotates the component each update.

Networking
using System;
using Sandbox;

public class UnitStunVfx : Component
{
	[Property] public ParticleEffect ParticleEffect { get; set; }

	private float _rotationSpeed;

	protected override void OnAwake()
	{
		base.OnAwake();

		_rotationSpeed = Game.Random.Float( 350f, 450f ) * (Game.Random.Int( 0, 1 ) == 0 ? 1f : -1f);
	}

	protected override void OnUpdate()
	{
		base.OnUpdate();
			
		LocalRotation = LocalRotation.RotateAroundAxis( new Vector3( 0f, 0f, 1f ), _rotationSpeed * Time.Delta );
	}
}