Offset doesn't work on child node

MagicLordMagicLord Posts: 578Unconfirmed
edited September 13 in 3D

Hi there,

I try to apply an offset to the position of a child node, but it has no effect, while the scaling to the child works
Any idea or it is some bug ?

This is my code

export(PackedScene) var playerModel
var playerModelNode
export var scaling = 0.1
export var offset = Vector3(0,0,0)


    func _ready():

        playerModelNode = playerModel.instance()
        *
        var nodeOrigin = $head/Camera/originMesh
        nodeOrigin.add_child(playerModelNode) 
        *
        var scale = Vector3(scaling,scaling,scaling)
        playerModelNode.set_scale(scale)
        *
        var posPlayerModel = playerModelNode.global_transform.origin
        playerModelNode.global_transform.origin = posPlayerModel + offset

Answers

  • MagicLordMagicLord Posts: 578Unconfirmed
    edited September 13

    I tried set-translation and it doesn't work either, it's like offsets to an instance of a PackedScene doesn't work.

    playerModelNode.set_translation(offset)

  • MagicLordMagicLord Posts: 578Unconfirmed
    Answer ✓

    I found a work around
    scaling and offset can be done on the parent node.

    export(PackedScene) var playerModel
    var playerModelNode
    export var scaling = 0.1
    export var offset = Vector3(0,0,0)
    
    
    func _ready():
    
        playerModelNode = playerModel.instance()
        *
        var nodeOrigin = $head/Camera/originMesh
        nodeOrigin.add_child(playerModelNode) 
         *
        nodeOrigin.set_scale(Vector3(scaling,scaling,scaling))
        nodeOrigin.set_translation(offset) 
    

    It's definitively a bug.

Sign In or Register to comment.