Add CharacterController.Resize for quick crouching implementation for characters
This commit is contained in:
@@ -84,13 +84,13 @@ public:
|
||||
API_PROPERTY() void SetRadius(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the capsule, measured in the object's local space. The capsule height will be scaled by the actor's world scale.
|
||||
/// Gets the height of the capsule as a distance between the two sphere centers at the end of the capsule. The capsule height is measured in the object's local space and will be scaled by the actor's world scale.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(150.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetHeight() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the height of the capsule, measured in the object's local space. The capsule height will be scaled by the actor's world scale.
|
||||
/// Sets the height of the capsule as a distance between the two sphere centers at the end of the capsule. The capsule height is measured in the object's local space and will be scaled by the actor's world scale.
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetHeight(float value);
|
||||
|
||||
@@ -194,6 +194,13 @@ public:
|
||||
/// <returns>The collision flags. It can be used to trigger various character animations.</returns>
|
||||
API_FUNCTION() CollisionFlags Move(const Vector3& displacement);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the character height and center position to ensure its feet position stays the same. This can be used to implement a 'crouch' functionality for example. Maintains the same actor position to stay in the middle of capsule by adjusting center of collider accordingly to height difference.
|
||||
/// </summary>
|
||||
/// <param name="height">The height of the capsule, measured in the object's local space.</param>
|
||||
/// <param name="radius">The radius of the capsule, measured in the object's local space.</param>
|
||||
API_FUNCTION() void Resize(float height, float radius);
|
||||
|
||||
protected:
|
||||
/// <summary>
|
||||
/// Creates the physics actor.
|
||||
@@ -210,6 +217,9 @@ protected:
|
||||
/// </summary>
|
||||
void UpdateSize() const;
|
||||
|
||||
private:
|
||||
void GetControllerSize(float& height, float& radius) const;
|
||||
|
||||
public:
|
||||
// [Collider]
|
||||
#if USE_EDITOR
|
||||
@@ -220,6 +230,7 @@ public:
|
||||
void AddMovement(const Vector3& translation, const Quaternion& rotation) override;
|
||||
bool CanAttach(RigidBody* rigidBody) const override;
|
||||
RigidBody* GetAttachedRigidBody() const override;
|
||||
void SetCenter(const Vector3& value) override;
|
||||
|
||||
// [IPhysicsActor]
|
||||
void OnActiveTransformChanged() override;
|
||||
|
||||
Reference in New Issue
Block a user