Hey there new to the love2d scene. What I am trying to do is make the camera follow the player sprite based off the x and y values of player.body. What ends up happening with the code I've written below is the camera does indeed follow the players sprite. However. There is some weird behavior when the sprite rotates. the sprite no longer rotates according to the location of the mouse. Once the camera is implemented it tends to through off the player rotation for some reason. I don't need the camera to rotate to the players sprite, I just need it to follow the player based off movement.
I've attached a screen shot to get a better reference to whats going on. the white dot represents the mouse...
thank you guys!
snillor wrote: ↑Wed Oct 30, 2019 6:55 pm
Hey there new to the love2d scene. What I am trying to do is make the camera follow the player sprite based off the x and y values of player.body. What ends up happening with the code I've written below is the camera does indeed follow the players sprite. However. There is some weird behavior when the sprite rotates. the sprite no longer rotates according to the location of the mouse. Once the camera is implemented it tends to through off the player rotation for some reason. I don't need the camera to rotate to the players sprite, I just need it to follow the player based off movement.
I don't understand your problem very well, but it seems to have to do with coordinate systems.
The mouse coordinates are always in the screen coordinate system. The player coordinates are typically in the world coordinate system. You need to convert one to the other before subtracting them: either convert the player to screen coordinates, or the mouse to world coordinates. The former is easier, because the player is typically at the centre of the screen, so the coordinate is where the camera centre points to. The latter is more powerful because it's also useful for e.g. detecting clicks on world objects.
Hump has camera:cameraCoords and camera:worldCoords to perform this conversion.
Other than that, you will have to provide a complete runnable example if you want help.