Hi,
I have this working code in godot 3.x

node.set_global_transform(Transform(a,b))

where a,b are both Vector3

When I tried convert it to 4beta3 to this:

node.set_global_transform(Transform3D(a,b))

I got error "No constructor of "Transform3D" matches "Transform3D(Vector3, Vector3)"

I looked through doc and it seems nothing much changed except name so I don't know why it doesn't work now. Can someone please help explain to me?
https://docs.godotengine.org/en/latest/classes/class_transform3d.html#class-transform3d

  • cybereality
    Sorry my bad. I wasn't sure how the code works so it was hard to explain correctly. But I finally got it work with this

    node.set_global_transform(Transform3D(Basis(),b))

    I think it's correct according to doc.
    It sets the block rotation/location in front as the player moves forward, so player can move forever. Using Vector3 can work in 3.x but probably needs to be more specific now for 4 I guess.

It says right there in the docs that there is no constructor that takes 2 Vector3s. Neither does Godot 3.x, so I have no idea how that ever worked. What is in those vectors and what are you trying to do?

    cybereality

    It's a runner game and the code is for swapping block nodes so it runs forever. Basically it goes something like this (3.x):

    var offset = 240
    ...
    func _physic_process(delta):
    	var a = Vector3(0, 0, 0)
    	var b = Vector3(offset, 0,5)
    	var node = get_node('/root/world/Scene Root')
    	var node1 = ...
    
    	if cycle ==1:
    		node.set_global_transform(Transform(a,b))
    	if cycle == 2:
    		...

    So I'm confused, should it not work on 3.x or should it work on 4 (with Transform3D)? 😕

    @cybereality

    I may have fixed it by adding more Vector3.ZERO 😆

    node.set_global_transform(Transform3D(a,b,a,a))

    (since a is Vector3.ZERO)

    The blocks look like it loaded ok but now I gotta fix player movement first to see the effect..

    Look at the documentation. What you originally said was not supported on any version of Godot (4.0 or 3.x) so it's likely there was some implicit casting going on. Which means it may have magically worked, but not really, since you weren't calling it with the correct values. But I don't know what those values are, or what you are doing, so I can't tell you how to call it correctly.

      cybereality
      Sorry my bad. I wasn't sure how the code works so it was hard to explain correctly. But I finally got it work with this

      node.set_global_transform(Transform3D(Basis(),b))

      I think it's correct according to doc.
      It sets the block rotation/location in front as the player moves forward, so player can move forever. Using Vector3 can work in 3.x but probably needs to be more specific now for 4 I guess.

      Doing the Transform3D(Basis(),b) version would be the equivalent of Transform3D(Vector3(1,0,0),Vector3(0,1,0),Vector3(0,0,1), b).
      The first 3 vectors define the rotation and scale. Having them as those values means no rotation and a scale of 1. Then the 4th vector3 is the position.

      Which means you can just do:

      node.global_position = b

      And it would be the same thing, right?

        cybereality Got error set index "global_translation" (base Node3D) with type Vector3. 😅

        But it's working with Transform3D so that's alright, Thanks guys.

        Sorry, global_position, I forgot this was Godot 4.0.