Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Imports.XinputGamePadSetState() using 76% of the CPU (Unity 2019.4.29f1) #45

Open
lazydevyo opened this issue Sep 14, 2022 · 3 comments

Comments

@lazydevyo
Copy link

Yesterday i installed the latest unity package you provided at the release page. I looked at the example, and i added the GamePad.SetVibration() function at my main code, into the FixedUpdate(). Everything worked fine, the next day, i launched Unity tried the game and i noticed a huge performance issue, game was running at 4 FPS in editor also after Building, the profiler is showing me that GamePad.SetVibration() => Imports.XinputGamePadSetState() is using 76% of the CPU, Any idea whats wrong?

@speps
Copy link
Owner

speps commented Sep 14, 2022

That function shouldn't be called every update, you need to set it less often according to your game. It'll continue vibrations even if you don't call the function.

@lazydevyo
Copy link
Author

That function shouldn't be called every update, you need to set it less often according to your game. It'll continue vibrations even if you don't call the function.

The demo itself calls the function in a fixed update, and sets the vibration based on the trigger's value, I need to constantly vibrate the controller since I'm making a racing game, The demo also causes a huge performance drop running at 4fps. there's clearly a problem here.

@lazydevyo
Copy link
Author

if i disconnect the controller in runtime, it stops using CPU, and performance gets restored to normal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants