I’m still new to the Unreal Engine & C++, & I’m having difficulties understanding how to access an object’s components, specifically the Rigid Body component. I’m coding in C++ a simple first person game where you can pick up, hold & drop objects. I just want to put the picked up object to sleep or disable any physics on it, then reenable the physics when you drop it.
I understand that I can get components by using the function GetComponentByClass() but I don’t understand the syntax for the parameter. I saw this forum post about this issue but I don’t understand how to use this function after reading the answer.
While looking for answers, I found that there’s a UPrimitiveComponent that has a BodyInstance variable that has a single rigid body. It also has a PutInstanceToSleep() & WakeInstance() function which definitely sounds like what I want. How do I use it? What’s the syntax to access it (UPrimitiveComponent::GetBodyInstance(ObjectHeld)->WakeInstance()? or UPrimitiveComponent::GetBodyInstance(ObjectHeld)::WakeInstance()?) I saw this forum post that about this issue but again I don’t understand the answer or the syntax it provides.
Could someone explain to me how to access components of an object in C++?