-
-
Notifications
You must be signed in to change notification settings - Fork 23.8k
Description
Tested versions
-Reproducible in version 4.3
System information
Windows 11 - Godot Engine v4.3.stable.official.77dcf97d8 - OpenGL API 3.3.0 NVIDIA 546.18 - NVIDIA GeForce RTX 4060 Laptop GPU
Issue description
When you try to set up CapsuleShape2D programatically, it does not allow you to set Radius and Height at the same time, if you set the Radius first, then it will be overriden when setting the height later, or vice-versa, if you set the Height first, it will be overriden when setting the Radius later in a way that Height = 2*Radius, having a final circular collisionShape.
Steps to reproduce
-Set a basic 2D Scene containing an StaticBody2D as parent, and Sprite2D and CollisionShape2D as children.
-For this issue, Sprite can be whatever (or even unnecesary, I am just replicating the configuration of the scene I created).
-Set the CollisionShape2D to be a CapsuleShape in the editor.
-Create the following script for the StaticBody2D:
extends StaticBody2D
# Instantiating the Sprite2D and the CollisionShape2D
@onready var sprite: Sprite2D = $Sprite2D
@onready var collision_shape: CollisionShape2D = $CollisionShape2D
# Setting the initialization of the Scene
func _ready() -> void:
configure_col_shape()
# Setting the texture and the CollisionShape from the Resource
func configure_col_shape():
# Configura el CollisionShape2D
if collision_shape and collision_shape.shape is CapsuleShape2D:
collision_shape.shape.radius = 100
collision_shape.shape.height = 20
print("Radio: ", collision_shape.shape.radius, " Altura: ", collision_shape.shape.height)-According to what happened to me, Collisionshape.shape.radius should be equal to 10 and Collisionshape.shape.height should be equal to 20.
Minimal reproduction project (MRP)
I do not have right now an MRP, but if instructions above are followed, the bug is easily replicable.