[go: nahoru, domu]

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

Disable Mobile Game Controls #140

Open
hmbrg opened this issue Jun 29, 2023 · 2 comments
Open

Disable Mobile Game Controls #140

hmbrg opened this issue Jun 29, 2023 · 2 comments

Comments

@hmbrg
Copy link
hmbrg commented Jun 29, 2023

When including a Spline scene with game controls, on mobile devices I get on-display game controls that don't seem to work correctly. There doesn't appear to be any props to disable them. How can I fix that?

CleanShot 2023-06-29 at 04 09 08@2x
@wholelott4
Copy link

I'm not sure if there is another way to do it, but you can do it like this.

import { useRef } from 'react';
import Spline from '@splinetool/react-spline';
import { Application } from '@splinetool/runtime';

export default function App() {
  const spline = useRef<any>();

  function onLoad(splineApp: Application) {
    if (splineApp) {
      spline.current = splineApp;
      const controls = splineApp.controls
      if(controls?.joysticks) {
        const joysticks = [...controls.joysticks]
        const correctJoystick = joysticks.filter(e => e !== undefined)
        correctJoystick[0][0].destroy()
      }
    }
  }

  return (
    <div>
      <Spline
        scene="https://prod.spline.design/Vco6aLQFoV7ZvEQL/scene.splinecode"
        
      />
    </div>
  );
}

the Spline scene will retrieve to you informations about the joysticks, and there is a function called "destroy", which you can use.

Note that I applied some validations to reach the joystick on this sample code, it might be different for you using your scene, so debug it.

@hmbrg
Copy link
Author
hmbrg commented Jul 1, 2023

Thanks for the response! I tried the code snippet, but unfortunately it only removes the left joystick. The button on the right is still there. I've also looked at the controls object and there doesn't seem to be any destroy function for that button.

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

No branches or pull requests

3 participants