Should 2d camera target move the camera ?

I'm using raylib-go . I'm trying to figure out how to get the 2d camera to follow a moving object. I'm setting the target of the camera to the x,y of my rectangle thinking that it will move the camera but it doesn't. I can move the camera by changing the offset when i push a button, but what I want to do is have the camera always follow a target that's moving when a button isn't pushed. Should camera.Target do this ?

Comments

  • Hi Eon1,

    camera.target represents the origin point in case of camera rotation and zoom, probably you want to follow player.

    camera.offset represents the offset (displacement) from camera.target, probably you also want to follow player.

    Check examples/core/core_2d_camera for reference.
  • Ok so I have to calculate the offset to get the camera to move . I can't just change the Target because the target is only used for rotation and zoom ? Is there a position or something like that that I can use to calculate the offset ? or can I just use Target ? is Target the same as Position ?
  • Nevermind I got it working. Thanks for the help.
  • Hi Eon1! Nice to read you already managed with the Camera 2D.

    I checked lots of 2D camera systems to design raylib one but maybe it's not enough intuitive, please, if you have any proposal to improve it, just let me know.

    One of the goals I seek with raylib is making it simple and easy-to-use, I'm sure there are a lot of parts that can be improved...
  • It was fairly easy once I understood how it was all put together. I would hate to try to improve on what you have already because i'm fairly new and might not fully understand what I'm trying to make better :smile:

    One thing I would like to see are more tutorials for newbs like myself. Like right now I'm trying to figure out how to only draw what's visible by the camera or even within a certain distance from the player, but I'm having a hard time finding material online on how to go about doing that with raylib.
  • I think i figured out how to not draw things off screen but still it would be nice to have some more tutorials or information on how to do things you have to do in most games. That would be my only suggestion. Other than that working with raylib is very enjoyable.
  • Hi Eon1,

    About not drawing things outside camera area, you can skip that part for now if working on small or simple 2D game, raylib can handle some thousand sprites drawing pretty well.

    Completely agree on the tutorials required, just don't have enough time to do everything... but I'm planning to do a video series on raylib development. I'll keep you updated!
  • Great that sounds awesome I look forward to it. I see you on this forum answering everyone's questions. I know most people on here really appreciate that. I know I do. Keep up the great work and thank you for the easy to use engine .
Sign In or Register to comment.