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

Updating rotation and position of AnimatableBody2D in code only updates using the last instruction when sync to physics is enabled #76685

Open
ZeAntwan opened this issue May 2, 2023 · 2 comments · May be fixed by #100056 or #99012

Comments

@ZeAntwan
Copy link

ZeAntwan commented May 2, 2023

Godot version

4.0.2.stable, 4.1.dev1

System information

Windows 10

Issue description

In an attempt to create a moving and rotating platform that syncs to physics, I created an AnimatableBody2D and updated the code to manipulate my object rather than use an animation.

The code I'm using is this:

func _physics_process(delta):
	global_rotation_degrees += delta*10
	global_position.x += delta*10

What I expect:
A clockwise rotating object that goes from left to right.

What I get:
Only the last instructions updates the object, in this case, the position.

Doing this on the parent class (StaticBody2D) OR disabling the sync to physics makes it work, but you lose the sync to physics.

I might be doing this wrong, but couldn't find info around it, so sorry if this is a non-issue.

Steps to reproduce

  • Create AnimatableBody2D node
  • Add a sub node for visibility (Sprite2D with Godot logo)
  • Add script to AnimatableBody2D with
    '''
    func _physics_process(delta):
    global_rotation_degrees += delta10
    global_position.x += delta
    10
    '''
  • Object will only translate to the right instead of translating and rotating

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented May 2, 2023

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2023
@Calinou Calinou reopened this May 2, 2023
@Rindbee
Copy link
Contributor

Rindbee commented May 3, 2023

You can combine rotation/position/scale into Transform2D in advance and then set transform.

Or use RemoteTransform2D, then modify the position/rotation/scale of the RemoteTransform2D.

@ZeAntwan ZeAntwan changed the title Updating rotation and position of AnimatableBody2D in code only updates using the last instruction Updating rotation and position of AnimatableBody2D in code only updates using the last instruction when sync to physics is enabled May 4, 2023
@huwpascoe huwpascoe linked a pull request Dec 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants