FPS dropped after while using Neurosky Plugin

I’m using Mindwave Plugin from the following link:

and I created a simple code to take the output EEG readings of the Neurosky headset to move the car forward, but whenever I run the game, the fps drops to 2fps

[SerializeField, Range(0.0f, 100.0f)]
	[Tooltip("Player must hold its attention over this value to initialize car movement \"Focus phase\"")]
	private float m_RequiredAttention = 10.0f;

	private void Start()
	{
		Application.targetFrameRate = 30;
		MindwaveManager.Instance.Controller.OnUpdateMindwaveData += OnUpdateMindwaveData;
	}

	public void OnUpdateMindwaveData(MindwaveDataModel _Data)
	{
			if (_Data.eSense.attention >= m_RequiredAttention)
			{
			// Make the car move forward
			transform.position += transform.forward * 30 * Time.deltaTime;
			}
	}

Can anyone tell me what to do, it’s for my graduation project

This is a quick answer, but, hopefully some help.

Neurosky updates at ~1Hz. If your code is waiting for the API to return a value it will probably wait for this which is the delay you’re experiencing.

Move the API requests to a coroutine that changes a variable you respond to in update. e.g. move the API code to an IEnumerator that changes a float ‘attention’, and in Update respond to that.

It’s btw a bit sketchy what NeuroSky measures (they’ve always been very black-box about it and there’s a very open question about EMG - e.g. facial movement - vs claimed ability to meaningfully measure EEG given their electrode setup). Might be worth noting in the dissertation! :slight_smile: