UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SphereComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
6#include "CoreMinimal.h"
9#include "SphereComponent.generated.h"
10
12
16UCLASS(ClassGroup="Collision", editinlinenew, hidecategories=(Object,LOD,Lighting,TextureStreaming), meta=(DisplayName="Sphere Collision", BlueprintSpawnableComponent), MinimalAPI)
17class USphereComponent : public UShapeComponent
18{
20
23 UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category=Shape)
24 float SphereRadius;
25
26public:
32 UFUNCTION(BlueprintCallable, Category="Components|Sphere")
34
35 // @return the radius of the sphere, with component scale applied.
36 UFUNCTION(BlueprintCallable, Category="Components|Sphere")
37 float GetScaledSphereRadius() const;
38
39 // @return the radius of the sphere, ignoring component scale.
40 UFUNCTION(BlueprintCallable, Category="Components|Sphere")
41 float GetUnscaledSphereRadius() const;
42
43 //~ Begin UPrimitiveComponent Interface.
46 ENGINE_API virtual struct FCollisionShape GetCollisionShape(float Inflation = 0.0f) const override;
47 ENGINE_API virtual bool AreSymmetricRotations(const FQuat& A, const FQuat& B, const FVector& Scale3D) const override;
48 //~ End UPrimitiveComponent Interface.
49
50 //~ Begin USceneComponent Interface
51 ENGINE_API virtual FBoxSphereBounds CalcBounds(const FTransform& LocalToWorld) const override;
53 //~ End USceneComponent Interface
54
55 //~ Begin UShapeComponent Interface
57 //~ End UShapeComponent Interface
58
59 // Get the scale used by this shape. This is a uniform scale that is the minimum of any non-uniform scaling.
60 // @return the scale used by this shape.
61 UFUNCTION(BlueprintCallable, Category="Components|Sphere")
62 float GetShapeScale() const;
63
64 // Sets the sphere radius without triggering a render or physics update.
65 inline void InitSphereRadius(float InSphereRadius) { SphereRadius = InSphereRadius; }
66};
67
68
69// ----------------- INLINES ---------------
70
71inline float USphereComponent::GetScaledSphereRadius() const
72{
73 return SphereRadius * GetShapeScale();
74}
75
76inline float USphereComponent::GetUnscaledSphereRadius() const
77{
78 return SphereRadius;
79}
80
81inline float USphereComponent::GetShapeScale() const
82{
83 return GetComponentTransform().GetMinimumAxisScale();
84}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
@ UpdateBodySetup
Definition BoxComponent.cpp:94
Definition PrimitiveSceneProxy.h:296
FIntermediate3DTransform GetComponentTransform(const UObject *Object)
Definition MovieSceneTracksCustomAccessors.cpp:18
Definition CollisionShape.h:21
Definition BoxSphereBounds.h:25