Jump to content
  • Advertisement

Runcible

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

147 Neutral

About Runcible

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. I figured this one out now, thanks Zakwayda for pointing me in the right direction, I just rotated the sprite positions by the inverse of the cameras rotation and this gave me what I was looking for. I must say that as I'm using the built in Godot functions (e.g. Vector2.rotate(-camera_rotation)) I don't fully understand the maths behind it, so I should read up on the actual calculations to understand this better.
  2. Thanks for the hints, I'm unfortunately just doing a basic prototype using Godot, so not dealing directly with any geometry or transformations manually at the moment. I may have explained poorly in my first post so I'll try and clarify: The red "dot" in the middle is the player sprite. The camera is centred on the player in the example, but doesn't have to be. The player can move forward, backwards, left and right through the world, past various other sprites ("A", "B", and "C") In reality these other sprites (and the player sprite itself) could overlap each other (i.e. one sprite is "in front" of something, or "behind" something, shown through correct draw order) When the camera rotates, it changes the viewing angle such that objects should appear "in front" or "behind" differently. (For example, with no rotation, say the player sprite is below ("in front of") A, so should be drawn after (basic Y sorting). Camera rotates 180 degrees. The player should now be above ("behind") A, and so drawn earlier. I understood the theory there of transforming the sprite positions into a different space so that their y's would be relative to the rotation, and tried a few of the points you suggested Zakwayda, but can't seem to get the right results. I wonder if you could explain how the camera position is related to the sorting? I thought only the rotation would be relevant to it, because no matter where the current camera X/Y is, the draw order would be the same, and only change when it's rotated.
  3. I'm having trouble working out how to recalculate 2D sprite sorting / draw order based on camera rotation. In the example below: Screen 1 shows a non-rotated typical "top down 2D" scene, where the grey objects can be sorted based on their screen Y position, drawn from top to bottom, so in this case B, A, C. Screen 2 shows the situation after the player/camera rotates clockwise, with the original screen up vector (green) and the new up vector (red). In this situation, sorting by object Y position will not work, because A should now be drawn after C. What I need to do is to sort the objects not only by their Y position, but also relative to the new up vector and/or camera rotation, but I'm unsure how to handle this. Appreciate any help you can give!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!