Here’s what my events look like
As you can see, I have an object called “mouse” which I have it set to the position of the mouse/cursor and then I have the camera centered to the position of the cursor, but in game the “mouse” object moves around constantly and it doesn’t stop when I stop moving my mouse/cursor. How do I make it stop moving when I stop moving the cursor?
In this situation your brackets should be empty. I think i can see a comma “(,)”
Oh… Well I just got rid of it but, the object still moved around when I let go of my mouse while testing the game so that doesn’t seem to change anything unfortunately.
Do you have any behavior attached to the mouse object
I just tried to make it a draggable object and that didn’t seem to change anything either.
That’s a little problem with your logic. If your cur or is 10px far from the middle of the screen, the object will go there, then the camera, and as the camera where the object is, the object is in the middle, but the cursor is still 10px away from that, so the object goes 10px further again, and it goes on until your cursor is in the middle of the screen.
Here, you have two options to make it work.
The first is impossible in GDevelop and it would be to teleport the cursor to the middle of the screen just after the camera.
The second would be to use a variable instead of an object. To do so you would
- Get the difference between variable oldCursor.x and the cursor X position
- Same for Y
- Apply the differences to the camera
- Set the oldCursor.x to the current cursor X position
- Same for Y
By using differences the camera moves only when there actually is a difference in position.
sorry for the fairly late reply, but can you show how to do this with events? im not sure how to apply the difference to the camera and im trying to do the same thing