+2 votes

Like in blender where I can save apply scaling of an object, and make its value 1 and keep the scaling, how can I achieve this in godot. I want to scale an object but after the scaling I want to save the scaling and make it's scaling value 1.

in Engine by (16 points)

2 Answers

0 votes

Hi,
you cant do it in the editor environment.

You have to write a script for that. This class can help you:

https://docs.godotengine.org/en/stable/tutorials/content/procedural_geometry/meshdatatool.html?highlight=meshDatatool

would look like. This only works with one surface and does not work on primitives

tool
extends MeshInstance

export(bool) var update setget _update

func _update(value):
    if value:
        update()

func update():
    var mdt = MeshDataTool.new()
    #will only work with 1 surfcae by now
    mdt.create_from_surface(mesh, 0)

    #step through every vetex of the surface
    for i in range(mdt.get_vertex_count()):
        #multiply position and normal by scale to apply scaling
        var vertex = mdt.get_vertex(i) * scale
        var normal = mdt.get_vertex_normal(i) * scale
        #write it back to the surface
        mdt.set_vertex(i, vertex)
        mdt.set_vertex_normal(i, normal)

    #make a new mesh
    mesh = ArrayMesh.new()
    #commit changes to mesh
    mdt.commit_to_surface( mesh )

    #reset scale to 1
    scale = Vector3(1,1,1)
    #tell the inspector something has changed
    property_list_changed_notify()
by (4,088 points)
0 votes

depending on what you need, just make it a child. the parent is scale 1 and child is scale x?

or maybe use global_scale and leave scale alone?

https://docs.godotengine.org/en/stable/classes/class_node2d.html#class-node2d-property-global-scale

by (1,939 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.