From 7459a0ef86cb0ee260b126a2fe47c194503531a3 Mon Sep 17 00:00:00 2001 From: Philippe St-Amand Date: Tue, 10 Jan 2023 16:43:28 -0500 Subject: [PATCH] fixed capsule resize example code --- How_To/change-shape-dimensions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/How_To/change-shape-dimensions.md b/How_To/change-shape-dimensions.md index 19b8e55..faafb44 100644 --- a/How_To/change-shape-dimensions.md +++ b/How_To/change-shape-dimensions.md @@ -13,8 +13,10 @@ Changing the character physics shape is as simple as changing the "Shape Type" i If you wish to change the character collider's dimensions at runtime, you would simply do something like this: ```cs -CapsuleCollider* capsuleCollider = (CapsuleCollider*)PhysicsCollider.ColliderPtr; // cast to the type of collider you have now (could be CylinderCollider, BoxCollider, etc...) -capsuleCollider->Geometry.Radius = 1f; // edit the Geometry of the collider +CapsuleCollider* capsuleCollider = (CapsuleCollider*)physicsCollider.ColliderPtr; +CapsuleGeometry capsuleGeometry = capsuleCollider->Geometry; +capsuleGeometry.Radius = 1f; +capsuleCollider->Geometry = capsuleGeometry; ``` Note that you'll need to make sure that the function in which you do this has the `unsafe` declaration. You must also not forget to write back to the `PhysicsCollider` component in the character update job. \ No newline at end of file