UPhysicsHandleComponent* PhysicsHandle = GetPhysicsHandle();

UPhysicsHandleComponent* PhysicsHandle = GetPhysicsHandle();

Simple question here. Whats going on under the hood when we say — UPhysicsHandleComponent*----
1 - If this is a pointer what is it pointing towards and how can i find out for other cases where code is used the same way?

2- From My understanding in this line of code PhysicsHandle is a variable and the result of GetPhysicsHandle() is being assigned to it(PhysicsHandle).

Can someone explain whats going on under the hood here?

  1. All that says is “pointer to UPhysicsHandleComponent”.

    UPhysicsHandleComponent* Thing = /*...*/;
    

    Thing would be pointing to a memory location, and at that location there would be an object of type UPhysicsHandleComponent. All UObjects are dealt with via pointers.

  2. GetPhysicsHandle() is a function that returns UPhysicsHandleComponent* which is used to initialise PhyicHandle. Pointers are implicitly convertible to bool where nullptr is false and any other value is true. The following two lines are equivalent.

    if (PhysicsHandle)
    if (PhysicsHandle != nullptr)
    

Thanks so much.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms