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

The protagonist of the 2d camera experiences severe shaking #83135

Closed
dream-young-soul opened this issue Oct 11, 2023 · 2 comments
Closed

The protagonist of the 2d camera experiences severe shaking #83135

dream-young-soul opened this issue Oct 11, 2023 · 2 comments

Comments

@dream-young-soul
Copy link

dream-young-soul commented Oct 11, 2023

Godot version

Godot v4.1.2.stable.mono

System information

Godot v4.1.2.stable.mono - Windows 10.0.23560 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3050 (NVIDIA; 31.0.15.5009) - 12th Gen Intel(R) Core(TM) i5-12490F (12 Threads)

Issue description

Regarding this issue, I checked the relevant information. At first I thought it was the official document Fixing jitter, stutter and input lag

#7774, there is another discussion on this topic, but I am not making a pixel game.

until i saw
#74203
#77813
I'm not sure why this topic was closed, because I also tried using force_update_scroll() and it didn't work, maybe because I used Tween for character movement?

I tried writing a piece of code using 3.5.3 and found that the character did not jitter. But version 4.x is available. Please see video for details

4.1.2:

4.1.2.mp4

3.5.3:

3.5.3.mp4

Steps to reproduce

  1. Create a Node2D node
  2. Create a Camera2D node
  3. Create a CharacterBody2D node, which contains a Sprite2D node and a RemoteTransform2D node. The RemoteTransform2D node [remote_path] points to Camera2d
    Create a player.gd script pointing to the CharacterBody2D node
extends CharacterBody2D

var _tween:Tween = null

func_process(delta):
    var speed = Vector2.ZERO
    var s:int = 8
    if Input.is_action_pressed("ui_right"):
        speed.x = s

    if Input.is_action_pressed("ui_left"):
        speed.x = -s

    if Input.is_action_pressed("ui_up"):
        speed.y = -s

    if Input.is_action_pressed("ui_down"):
        speed.y = s

    if speed != Vector2.ZERO:
        #self.position += speed
    if _tween == null or !_tween.is_running():
        _tween = self.create_tween()
        _tween.tween_property(self,"position",self.position + speed,0.02)
  1. Run

Minimal reproduction project

camera2d.zip
The example contains two folders, respectively the 3.5.3 and 4.1.2 projects.

@AThousandShips
Copy link
Member

AThousandShips commented Oct 11, 2023

#77813 was closed because it was a duplicate, see #77813 (comment)

I'd say this is a duplicate of #74203

@dream-young-soul
Copy link
Author

I checked #77813 (comment) carefully.
Thank you, I have solved this problem. The following is the c# code I added.

  
  int move_speed = 50;
  Callable callable = Callable.From<int>((int a) =>
  {
      Camera2D.ForceUpdateScroll();
  }
  );


  this.CreateTween().TweenMethod(callable, 0,100,move_speed);

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

No branches or pull requests

2 participants