Node3D won't move

Godot Version

4.2.1 Stable Official

Question

This is a weird problem ; I have two scenes instanciated in their own 3DViewport node, and they are basically of the same structure: A mesh in a Node3D.

But one rotates, and the other won’t bulge. It’s driving me insane, note that each root Node3D manually rotates fine in the scenes…

Here is the code:

extends CanvasLayer

@onready var shuttle_svp = %ShuttleSVP
@onready var mother_svp = %MotherSVP

func _ready():
    for shuttle in shuttle_svp.get_children():

        if shuttle.visible:
            print("shuttle: ", shuttle.name)
            var tween = create_tween()
            tween.tween_property(shuttle, "rotation:y", 360, 600)

    for mothership in mother_svp.get_children():

        if mothership.visible:
            print("mothership: ", mothership.name)
            var tween = create_tween()
            tween.tween_property(mothership, "rotation:y", 360, 600)
            tween.tween_callback(stoppation)


func stoppation():
    print("Finished!")

The shuttle rotates fine, the mothership, not :confused: the callback fires allright. No-ro-ta-tion.



I tried your code and all things are spinning :confused: but I have a Node3D as a parent to everything, I didn’t bother with subviewports. My first thought is that rotating something in a subviewport may behave weirdly, but you say that one spins and other doesn’t, so I don’t know. I guess there is something else preventing the rotation :thinking:

Also - a friendly tip: "rotation:y" is in radians. Rotating something by 360 radians sounds a lot like you want to rotate it by 360 degrees, like this:

# I changed the time to 1s here
tween.tween_property(mothership, "rotation:y", 2 * PI, 1)
2 Likes

Images in this topic:

  1. CanvasLayer scene
  2. Shuttle scene (the one that rotates fine)
  3. Mothership scene (the one that won’ move)

Thanks, @struhy_xd !
I finally found the problem (bug?) but not quite the solution, only a workaround.

Somehow, the mothership that has a camera won’t move. But we need a camera for the viewport. Weird thing number one is that I only need a camera in ONE of the mothership scenes instanciated inside the viewport, and then I can see all the other motherships, sharing the camera and its poistioning. Hmm.

Weird thing number two is that the scene providing the (viewport) camera is not behaving like the others, namely I can’t tween its root Node3D properties.

Workaround:

  1. Duplicate the camera scene, name it “Dummy”
  2. Remove the camera from all the “real” scenes
  3. Instantiate Dummy along the other motherships.

Yeah, I know, there must be something I’m missing. BTW I’m working on the beta of my new game, MegaBatar ; It needs an achievements system / screen.

"rotation:y" is in radians

Ahh yes, thank you.

These sub-viewport shinanigans are always a bit weird :slight_smile: I’d recommend having the structure like this:

  • Subviewport
    • Node3D (world container)
      • Motherships, players, enemies, whatever
      • Camera3D

That way it’s easier to reason about the structure. Having multiple cameras (on the motherships) could cause problems. It makes more sense to have a single camera per viewport. I think.

My guess is that because you are trying to tween externally, the code of the platform is setting its own rotation intentionally? Just a guess. I haven’t seen children of nodes cause issue like that.

Maybe because you renamed the camera the link to the code and camera relationship was broken.

1 Like

Are the Sub Viewports sharing a World3D?

1 Like