-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Camera2D zoom & smoothing problem #2074
Comments
I don't think this is a bug, I changed your code a little and I think it's pretty good now. try it. extends KinematicBody2D
var zoom = Vector2(1, 1)
var old_zoom
func _ready():
set_fixed_process(true)
func _fixed_process(delta):
if Input.is_action_pressed("ui_left"):
move(Vector2(-400 * delta, 0))
if Input.is_action_pressed("ui_right"):
move(Vector2(400 * delta, 0))
old_zoom = zoom
if Input.is_action_pressed("zoom_1"):
zoom = Vector2(1, 1)
if Input.is_action_pressed("zoom_2"):
zoom = Vector2(1.5, 1.5)
if Input.is_action_pressed("zoom_3"):
zoom = Vector2(2, 2)
if old_zoom != zoom:
get_node("Camera2D").set_zoom(zoom) |
Maybe this only hide the bug, I dunno, but the result is very better. |
This only hides the bug. |
Strange, I was thinking that this error is because the key press was calling the set_zoom often, but I tried this way and it's working fine. ...
if Input.is_action_pressed("zoom_1"):
get_node("Camera2D").set_zoom(Vector2(1, 1))
if Input.is_action_pressed("zoom_2"):
get_node("Camera2D").set_zoom(Vector2(1.5, 1.5))
if Input.is_action_pressed("zoom_3"):
get_node("Camera2D").set_zoom(Vector2(2, 2)) new code: var zoom = Vector2(1,1)
...
func _fixed_process(delta):
...
if Input.is_action_pressed("zoom_1"):
zoom = Vector2(1, 1)
if Input.is_action_pressed("zoom_2"):
zoom = Vector2(1.5, 1.5)
if Input.is_action_pressed("zoom_3"):
zoom = Vector2(2, 2)
get_node("Camera2D").set_zoom(zoom) I don't understood what's happening. |
I expected the camera stays with the bug. |
Well, bug confirmed for me. |
Yeap. I came to the same conclusion. It's on the update_scroll function. |
_update_scroll and smoothing is not synchronized. |
I know if we remove _update_scroll or do this, void Camera2D::set_zoom(const Vector2 &p_zoom) {
zoom = p_zoom;
Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
smoothed_camera_pos = old_smoothed_camera_pos;
}; it's works, but I dunno if I can do this. |
You can try creating a Pull Request and see if they aprove it. |
Do you tested this in your project? 2015-09-03 18:57 GMT-03:00 Federico notifications@github.com:
|
I can confirm this still happens on the 2.0 alpha build (20151030). |
Did you try the proposed patch da895e8 by @guilhermefelipecgs? |
Yes. Its working right. |
…nabled. Fix godotengine#16323 in master. Apply same solution of godotengine#2074 in rotation and offset.
…hing enabled Fix godotengine#16323 in 3.2 branch. Apply same solution of godotengine#2074 in rotation and offset.
…hing enabled Fix godotengine#16323 in 3.2 branch. Apply same solution of godotengine#2074 in rotation and offset.
…nabled. Fix godotengine/godot#16323 in master. Apply same solution of godotengine/godot#2074 in rotation and offset.
When the camera2D is moving and the zoom is updated, the camera movement makes a "stop" and then continues. Note this only occurs when using a smoothing factor other than 0.
I'm using dynamic changes in the camera properties using the Tween class and this is very noticeable. I don't know if this only applies to zoom only or other properties as well.
I include a test project: https://dl.dropboxusercontent.com/u/274954519/bugZoom2D.zip
Use LEFT-RIGHT to move and 1, 2, 3 to set the zoom.
Notice how the speed of the camera changes, even when setting the same zoom multiple times. Also, everything seems to work fine if the smoothing is 0
The text was updated successfully, but these errors were encountered: