Get a component by type
Pull out a component from this or from another actor.
From self
uclass ARoboticArm : AActor meta: api=MYGAME_API
{
component arm: static_mesh
func public void Spin() BlueprintCallable
{
get_component arm_ptr: arm from arm
if (arm_ptr) { arm_ptr->AddLocalRotation(FRotator(0, 45, 0)); }
}
}
get_component name: type from source expands to Type* name = source->FindComponentByClass<Type>();.
From another actor (Cast)
func public void ReactToHit(AActor* HitActor)
{
cast robot: robot from HitActor
if (robot)
{
robot->TakeDamage(10.0f);
}
}
cast x: T from src → T* x = Cast<T>(src);.
Raw C++ equivalent
When you need full control:
UStaticMeshComponent* Arm = GetComponentByClass<UStaticMeshComponent>();
if (Arm) { Arm->AddLocalRotation(FRotator(0, 90, 0)); }