I have one custom component on my character called “Use”, which simply line traces out and returns which type of
collision channel it hit (ECC_PhysicsBody, ECC_WorldStatic…).
Say I have 2 other custom actor components on my character, one that picks up objects with a physics handle
and one that tells doors and buttons etc. to activate when pushed.
At the moment, I have something like this for determining which type of object was hit:
auto HitResult = TraceRayCast();
if (HitResult.GetActor())
{
auto CollisionType = HitResult.GetComponent()->GetCollisionObjectType();
if (CollisionType == ECC_PhysicsBody)
{
UE_LOG(LogTemp, Warning, TEXT("Physics Object Hit."));
// Make grabbing component do its job
}
else if (CollisionType == ECC_GameTraceChannel1)
{
UE_LOG(LogTemp, Warning, TEXT("Door or button hit."));
// Activate whatever was hit (Door, button)
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Nothing Hit."));
}
}
How can I tell the other components on the actor to do their job from here?
If the Door had a “Open” component, How could I let my Use function tell it
its time to open?
I could be going at this very wrong I do not have any real programming training
but I want to know what you guys think.
Thank you!!!