I want to find what the area of my colision shape is so i can add y to another.
extends CollisionShape2D
# Called when the node enters the scene tree for the first time.
func _ready():
#get colision shape and find what height it is
var shape = get_shape()
var height = shape.get_area()
print(height)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
it seems get_shape returns the Shape2D shape property of CollisionShape2D according to the documentation of CollisionShape2D. This shape doesn’t have an area property as you can see in the documentation
It has a Rect2 rect property you can access via get_rect(). On this rect you can use get_area() to recover the area.
So if you want to get area, you can use var area = shape.get_rect().get_area(). If you want height, you probably want to use var height = shape.get_rect().size.y