Godot Version
v4.2.2.stable.mono.official [15073afe3]
Question
I made this tool script to more easily change the size of a box:
@tool
class_name SizeTool
extends Node3D
@export var size : Vector3
var shape3D : BoxShape3D
var mesh3D : BoxMesh
@export var apply : bool :
set(value):
_apply()
apply = false
func _ready():
shape3D = get_node("CollisionShape3D").shape
var mesh_instance = get_node_or_null("MeshInstance3D")
if mesh_instance:
mesh3D = mesh_instance.mesh
else: mesh3D = null
func _physics_process(_delta):
if !Engine.is_editor_hint():
return
if size == Vector3.ZERO:
return
#print(mesh_instance)
shape3D.size = size
if mesh3D != null :
mesh3D.size = size
return
func _apply():
shape3D = get_node("CollisionShape3D").shape
var mesh_instance = get_node_or_null("MeshInstance3D")
if mesh_instance : mesh3D = get_node_or_null("MeshInstance3D").mesh
if size == Vector3.ZERO:
print("can't set to 0")
return
shape3D.size = size
if mesh_instance : mesh3D.size = size
return
I have a “block” scene wich is just a staticbody3D, with a collisionshape3D and a meshInstance3D as children. The script works successfully to change the size of the block, but if I drag multiple blocks into a scene, they take the same size. This happens even if I make the blocks local. So how can I change the size on singular instances?