[Merge Fellas] Getting an unlimited shake effect bug with Chroma SDK? | Razer Insider
Skip to main content
Question

[Merge Fellas] Getting an unlimited shake effect bug with Chroma SDK?


Hey everyone,

First-time poster here. I'm a hobbyist dev working on my first little passion project in Unity, and I'm really excited to be integrating some Razer Chroma effects. I've hit a roadblock and was hoping some of the experienced devs in this community could point me in the right direction.

The project is a simple puzzle game I call "Merge Fellas". The goal is to trigger a quick, red "shake" or "pulse" effect across the keyboard whenever two game objects ("fellas") merge successfully.

The Problem:

I've managed to get the event to trigger, but instead of a single pulse, the effect gets stuck in an infinite loop. It creates an unlimited shake effect that flashes non-stop, and the only way to stop it is to kill the Unity editor.

I suspect it's a logic error in how I'm calling the Chroma function after the merge event, maybe creating a recursive loop, but I've been staring at it for hours and can't see the issue.

Here's a simplified version of my C# code:

```csharp // This function is called when two 'fellas' successfully merge void OnMergeComplete() { Debug.Log("Merge event triggered. Calling Chroma function."); TriggerChromaKeyboardShake(); }

// This function is meant to create a single red flash effect void TriggerChromaKeyboardShake() { // My logic to prevent the loop, but it's not working if (isEffectActive) return;

isEffectActive = true;
// Some pseudo-code for the Chroma SDK call
// Keyboard.Instance.SetStatic(new Color(1, 0, 0)); 
// ... then reset after a delay

// I suspect the problem is around here
isEffectActive = false;

}
 

The code above is just a snippet. I've put the full C# script and the Unity console log (which shows the function being called repeatedly) into a Google Doc for anyone who might be willing to take a closer look. I would be incredibly grateful for any advice.

Link to script and log file: https://docs.google.com/document/d/1R0hCpWO-G-g5nVJ5pVL1sL6V9pHtl-gQ1Ovulj5-ef4/edit?usp=sharing

Thanks in advance for your help! Glad to be a part of the community.

Did this topic help you find an answer to your question?

0 Replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings