// Function called every time the Transform of object changes in editor. void UVectorSceneComponent::OnUpdateTransform(E

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

// Function called every time the Transform of object changes in editor. void UVectorSceneComponent::OnUpdateTransform(E

Post by answerhappygod »

Function Called Every Time The Transform Of Object Changes In Editor Void Uvectorscenecomponent Onupdatetransform E 1
Function Called Every Time The Transform Of Object Changes In Editor Void Uvectorscenecomponent Onupdatetransform E 1 (223.69 KiB) Viewed 64 times
// Function called every time the Transform of object changes in editor. void UVectorSceneComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETelepo rtType Teleport) { Super::OnUpdateTransform(UpdateTransformFlags, Teleport); // ... // Get the global) location of the component in 3D Space TArray locations; auto location = GetComponentLocation(); locations.Add(location); // Get the "parent" of this scene component. If the scene component is actor root - the "parent" // is the attached parent actor. auto* parent = GetOwner(); if (parent->GetRootComponent() == this) { parent = parent->GetAttachParentActor(); } // If there is a parent (i.e. the scene component is not root for owner OR the owner acto r has a parent actor) if (parent != nullptr) { // Do the same check for grandparent - in this case, it's always the parent's att ached parent actor auto* grandparent = parent->GetAttachParentActor(); if (grandparent != nullptr) { auto intermediateLocation = grandparent->GetActorTransform(). Inverse().Tr ansformPosition(location); locations.Add(intermediateLocation); } auto localLocation = parent->GetActor Transform().Inverse(). TransformPosition(loca tion); locations.Add(localLocation); // ... } // } As we saw in class - this code works as expected and correctly displays up to 3 sets of coordinates for the point. This snippet is seen twice in the code above: component- >GetActor Transform(). Inverse(). TransformPosition(location). Explain what it does and what its purpose in the code is. Here's the full class for reference.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply