How to apply scaling

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Melodi

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.

:bust_in_silhouette: Reply From: klaas

Hi,
you cant do it in the editor environment.

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

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()
	
:bust_in_silhouette: Reply From: rakkarage

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?