Quantcast
Channel: Questions in topic: "lockcursor"
Viewing all articles
Browse latest Browse all 92

How to lock cursor in WebGL

$
0
0
Hello, At this point I am quite desperate so I decided to seek help personally. I have this ([project][1]) and in my newest build, when I looked around it would snap back ( probably after the cursor reached an edge of the screen) which is weird because that never occured before and I am using unity first person controller. Afterwards I tried to search trough the forum to see what the problem is. Ended up finding this code using System.Collections; using System.Collections.Generic; using UnityEngine; public class MouseLock : MonoBehaviour { // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { //Mouse lock and confine Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; Cursor.lockState = CursorLockMode.Confined; } if (Input.GetKeyDown("1")) { //and to unlock it is this: Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } } that I have tried implementing first just by adding it as a component onto the first person camera then the controller. None of that worked so I tried to insert it into the code of the controller, but that didn't help either. And now I am clueless of what to try next. Any help would be greatly appreciated since I am quite a noob and made the whole project just by tweaking stuff from tutorial videos. Also to see the original problem see the website after I changed the code it didn't even snap back it didn't even allow me to move any further from which I conclude, that the cursors just turns invisible but it doesn't lock. In my unity editor everything works fine. [1]: http://honeybadgerenvisionssuddenperpetuity.me/

Viewing all articles
Browse latest Browse all 92

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>