Godot Version
4.2.2
Question
Hello friends,
I would like some help.
I’m working on a platformer where you can resize the platforms in the level in real-time, but I can’t get it to work. I can make the sprite resize with no problem, but the CollisionShape doesn’t do anything. It is a child of a RigidBody, if that helps.
extends RigidBody2D
@export var up = true
@export var down = true
@export var left = true
@export var right = true
@export_range(0, 10, 0.1) var scale_speed
var x
var y
var shape = $CollisionShape2D.shape.extents
func _ready():
pass
func _process(delta):
if Input.is_action_pressed("ui_up"):
scale.y += scale_speed * delta
y += scale_speed * delta
if Input.is_action_pressed("ui_down") and scale.y > 0.5:
scale.y -= scale_speed * delta
y -= scale_speed * delta
if Input.is_action_pressed("ui_right"):
scale.x += scale_speed * delta
x += scale_speed * delta
if Input.is_action_pressed("ui_left") and scale.x > 0.5:
scale.x -= scale_speed * delta
x -= scale_speed * delta
shape.size = Vector2(x, y)
$CollisionShape2D.set_shape(shape)