We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Cannot add Mouse follow without crashing To Reproduce Add a PCamMouseFollow addon to a ProCam2D
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered:
Instead of dividing by 2, divide by 2.0.
Here's an improved version of the script that includes damping (smoothing):
@tool extends PCamAddon class_name PCamMouseFollow @export var max_offset := Vector2(300.0, 300.0) @export_range(0, 1) var damping := 0.1 var actual_offset := Vector2.ZERO func _init(): stage = "pre_process" func pre_process(camera, delta): if not enabled or camera._playing_cinematic: return var viewport = camera.get_viewport() var mouse_position = viewport.get_mouse_position() - viewport.size / 2.0 var viewport_size = viewport.size / 2 var desired_offset = Vector2( clamp(mouse_position.x / viewport_size.x, -1, 1) * max_offset.x, clamp(mouse_position.y / viewport_size.y, -1, 1) * max_offset.y ) actual_offset = actual_offset.lerp(desired_offset, damping) # Add the calculated offset to the existing camera position camera._target_position += actual_offset
Sorry, something went wrong.
No branches or pull requests
Describe the bug
Cannot add Mouse follow without crashing
To Reproduce
Add a PCamMouseFollow addon to a ProCam2D
Screenshots
![image_2024-09-30_135306800](https://private-user-images.githubusercontent.com/72965662/372074127-03627bc9-9e87-47b5-b296-d8ce35c5a7e1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODk1NTYsIm5iZiI6MTczOTI4OTI1NiwicGF0aCI6Ii83Mjk2NTY2Mi8zNzIwNzQxMjctMDM2MjdiYzktOWU4Ny00N2I1LWIyOTYtZDhjZTM1YzVhN2UxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE1NTQxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUyZmNlNmFhNzUxNGJlZDNkZWU2NTkzMjEzZDVkYTViZjdjMThjNmQ5YmEyNTdkNThjMWE3YWRlMTJhZjQ4MzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.RVQoNcatQOZ1J3wcLJ5pBcgqMDFgzK6vUBmSfxu4FG8)
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: