UPROPERTY() to preventUPROPERTY() marks for GC tracking — without it, pointer becomes danglingTWeakObjectPtr for optional references — doesn't prevent collection, check IsValid()NewObject() for UObjects — never raw new, GC won't track itUPROPERTY() required for Blueprint access — and for GC trackingUFUNCTION() for Blueprint callable/events — also required for replicationEditAnywhere vs VisibleAnywhere — edit allows changes, visible is read-onlyBlueprintReadWrite vs BlueprintReadOnly — controls Blueprint access levelBeginPlay after all components initialized — safe to access componentsPostInitializeComponents before BeginPlay — for component setupEndPlay for cleanup — called on destroy and level transitionPrimaryActorTick.bCanEverTick = falseGetWorldTimerManager().SetTimer()PrePhysics, DuringPhysics, PostPhysicsUPROPERTY(Replicated) for variable sync — implement GetLifetimeReplicatedPropsUFUNCTION(Server) for client-to-server RPC — must be Reliable or UnreliableHasAuthority() to check if server — before executing authoritative logicRole and RemoteRole for network role checks — ROLE_Authority is serverTSoftObjectPtr) load on demand — for optional or large assetsLoadSynchronous() or AsyncLoad for soft refs — don't access until loadedTSubclassOf — type-safe class selectionTSharedPtr for non-UObjects — reference counted, auto-deletesTUniquePtr for exclusive ownership — can't copy, moves onlyMakeShared() for creation — single allocation for object and control blocknew/delete with smart pointers — choose one patternIsValid() node before accessGetWorld() null in constructor — world doesn't exist yet, use BeginPlayFString for display, FName for identifiers — FName is hashed, faster comparison共 1 个版本