UnitStunVfx.cs

A component that plays a stun particle effect and continuously rotates its local transform. It randomizes a rotation speed on awake and applies rotation 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 );
	}
}