AActor::OnActorChannelOpen
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Called on the client when the actor's net channel is first opened. Allows the actor to read any custom data serialized by OnSerializeNewActor on the server.
Caveats & Gotchas
- • The data read here must exactly match what was written in OnSerializeNewActor on the server — byte order and field count must be identical, or the bunch will desync and the connection may be closed.
- • This function is called before any replicated properties arrive, so you cannot rely on replicated state being valid inside this callback.
- • Not called on the server or in standalone play — guard against editor/server execution if you call this in a shared code path.
Signature
virtual void OnActorChannelOpen(class FInBunch& InBunch, class UNetConnection* Connection) {}; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InBunch | class FInBunch& | The incoming bunch containing serialized actor data sent at channel open time. | — |
| Connection | class UNetConnection* | The net connection for which the actor channel is being opened. | — |
Return Type
void Example
Reading custom spawn-time data from the bunch C++
void AMyActor::OnActorChannelOpen(FInBunch& InBunch, UNetConnection* Connection)
{
Super::OnActorChannelOpen(InBunch, Connection);
// Read the uint8 that OnSerializeNewActor wrote
uint8 SpawnFlags = 0;
InBunch << SpawnFlags;
bSpecialSpawn = (SpawnFlags & 0x01) != 0;
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?