Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow Camera Implementation Preferences #37

Open
rhelsing opened this issue Feb 27, 2024 · 1 comment
Open

Follow Camera Implementation Preferences #37

rhelsing opened this issue Feb 27, 2024 · 1 comment

Comments

@rhelsing
Copy link

I would love to help contribute a toggleable follow camera option (like mario / uncharted) - when the player does not provide look direction input for X seconds, the camera autofollows the player direction. I have implemented this in a separate project, but would like to know if there is a preferred way you would like me to approach this for this project.

General approach in my other project:

  1. visible variable follow_camera, default to false on CameraController
  2. mouse_has_not_been_touched variable, set to false
  3. Timer on camera controller, set to 2 seconds, on timeout, sets mouse_has_not_been_touched to true
  4. when mouse input is detected sets mouse_has_not_been_touched to false and starts the timer

In player script, when follow camera is on and _camera_controler.mouse_has_not_been_touched and player is_moving, (not aiming), have the camera follow the player.

Screen Shot 2024-02-27 at 3 41 39 PM

Please let me know objections/considerations.

@NathanLovato
Copy link
Contributor

Hi, thanks for your interest in contributing to the project! And sorry for the reply delay; we have lots on our plates.

For the implementation, I'd go with either a steering equation (vector calculations) or using spherical-lerp with quaternions perhaps. This would make the code a bit simpler to read and edit.

If you use a timer to check for input, I wouldn't also have a boolean to check if the mouse has been touched. You could instead check if the timer is running or not. I don't have all the code in mind for this project, but I'd also ideally keep the camera code in the CameraController script over splitting logic between the camera and player controller scripts.

Let me know if you have any questions. Don't hesitate to open a PR directly with the change, and if it's okay with you, I could directly edit the code and comment where I'd make changes. That's how we usually do reviews in our team. A little extra note: please use snake case and no abbreviations in variable or function names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants