In my game the user can scroll the camera.
However, the scrolling is choppy.
I have my custom Camera object in a GameObject. I change the position of the GameObject holding the camera when I scroll. Like this:
local toMove=dt*CAMERA_SPEED -- I've tried varying the speed, doesnt help
pos.x=pos.x-toMove
go.set_position(pos)
For some reason this results in a choppy movement of the camera. Spine-animations, sprite-animations and everything else is running just fine without any lag. Any thoughts?
Yes, this happens in update().
There is not much else. The process:
1) The GameObject holding the camera receives input and internally saves the position of the cursor. 2) The update method reads the variable and checks if the cursor is near an edge and moves the camera as I described in the post above.
Which material should I change? The Camera-Object has no option for material…
Should I change all the regular “sprite” materials? @Andreas_Jirenius@sicher
I have only Spines and a Tilemap and I’ve tried changing both. It didn’t help.
The issue is only visible in the HTML5 version. I guess it has to do with performance, but it’s strange that everything else is animating and moving just fine.
The strange thing is that you say that spine animations and so on are not lagging. I can’t understand why spine and sprite animations are running at high fps while the camera movement is choppy and only in Safari. This, to me is a mystery. Could you please launch the desktop version of your game and bring up the web profiler, take a screen shot and share it with us? I’d also like to get some input from @Ragnar_Svensson or @Andreas_Tadic.
There’s no noticeable lag in any of the Spine animations and I can command other GOs to move on the screen by using the mouse and they will move perfectly fine.
BUT as soon as I start scrolling it scrolls choppy in Safari. The scroll-logic is minimal - it just reads the mouse-coordinates and moves the camera (as I wrote above).
The scrolling lag in Safari is there even if I remove all of the game and just leave a couple of GOs.
I wonder if it might be related to input handling in Safari. If you get choppy input that might affect the movement depending on your implementation. I’ll try to run some tests when I get the time.
@sicher I doubt it, I’ve tried just moving the camera to the left on each update loop and it scrolls choppy even when it’s just scrolling on its own. I’m making a small reproduction of the bug and will try to demonstrate it in action.
I can take a look if you can share a project as suggested. It’s likely nothing to do with performance given everything else is moving smoothly. I’ve also tried running some of our own examples using camera, and it works fine in Safari.
Some hints, although more a case of sanity checking…
The “dt” variable I assume is the (unmodified) update function parameter (it should be ~0.016 running at 60 fps, try printing it…).
CAMERA_SPEED is unmodified (static)
The game object position is not influenced anywhere else (e.g a message in another script or relative to another object).