> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksipredictor.md).

# Interface ksIPredictor

Namespace: [KS.Reactor.Client](/reactor/api-reference/ks.reactor.client.md)\
Assembly: KSUnity.dll

Predictor interface for smoothing/predicting entity movement and properties.

```csharp
public interface ksIPredictor
```

## Properties

### RequiresController <a href="#ks_reactor_client_ksipredictor_requirescontroller" id="ks_reactor_client_ksipredictor_requirescontroller"></a>

Does the predictor require a player controller?

```csharp
bool RequiresController { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

## Methods

### ClientUpdate(ksTransformState, Dictionary\<uint, ksMultiType>) <a href="#ks_reactor_client_ksipredictor_clientupdate_ks_reactor_kstransformstate_system_collections_generic_d" id="ks_reactor_client_ksipredictor_clientupdate_ks_reactor_kstransformstate_system_collections_generic_d"></a>

Updates the client transform and properties.

```csharp
bool ClientUpdate(ksTransformState state, Dictionary<uint, ksMultiType> properties)
```

#### Parameters

`state` [ksTransformState](/reactor/api-reference/ks.reactor/ks.reactor.kstransformstate.md)

Client transform to update with new values. Null if not smoothing a transform.

`properties` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2)<[uint](https://learn.microsoft.com/dotnet/api/system.uint32), [ksMultiType](/reactor/api-reference/ks.reactor/ks.reactor.ksmultitype.md)>

Smoothed client properties to update with new values. Null if there are no smoothed properties.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, this function will not be called again until the server transform or a server property changes.

### Detached() <a href="#ks_reactor_client_ksipredictor_detached" id="ks_reactor_client_ksipredictor_detached"></a>

Called when the predictor is removed. Predictors that use pooling will be returned to the pool.

```csharp
void Detached()
```

### Disabled() <a href="#ks_reactor_client_ksipredictor_disabled" id="ks_reactor_client_ksipredictor_disabled"></a>

Called when the predictor is disabled. May be called zero or more times. Called before [Detached](#KS_Reactor_Client_ksIPredictor_Detached). When an entity switches between the [NonInputPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md#KS_Reactor_Client_ksBaseEntity_NonInputPredictor) and [InputPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md#KS_Reactor_Client_ksBaseEntity_InputPredictor), this is called on the one that was switched off.

```csharp
void Disabled()
```

### Enabled() <a href="#ks_reactor_client_ksipredictor_enabled" id="ks_reactor_client_ksipredictor_enabled"></a>

Called when the predictor is enabled. May be called zero or more times. Called after [Initialize](#KS_Reactor_Client_ksIPredictor_Initialize_KS_Reactor_Client_ksBaseRoom_2cKS_Reactor_Client_ksBaseEntity_2cKS_Reactor_Client_ksBasePlayer_). When an entity switches between the [NonInputPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md#KS_Reactor_Client_ksBaseEntity_NonInputPredictor) and [InputPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md#KS_Reactor_Client_ksBaseEntity_InputPredictor), this is called on the one that was switched to.

```csharp
void Enabled()
```

### Initialize(ksBaseRoom, ksBaseEntity, ksBasePlayer) <a href="#ks_reactor_client_ksipredictor_initialize_ks_reactor_client_ksbaseroom_ks_reactor_client_ksbaseentit" id="ks_reactor_client_ksipredictor_initialize_ks_reactor_client_ksbaseroom_ks_reactor_client_ksbaseentit"></a>

Initializes the predictor. Called when the predictor is first assigned.

```csharp
bool Initialize(ksBaseRoom room, ksBaseEntity entity, ksBasePlayer player)
```

#### Parameters

`room` [ksBaseRoom](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseroom.md)

The room object.

`entity` [ksBaseEntity](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md)

Entity the predictor is smoothing. Null if the predictor is smoothing room or player properties.

`player` [ksBasePlayer](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseplayer.md)

Player the predictor is smoothing properties for. Null if the predictor is not smoothing player properties.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

False if the predictor could not be initialized and needs to be removed.

### InputUpdate(ksInput) <a href="#ks_reactor_client_ksipredictor_inputupdate_ks_reactor_ksinput" id="ks_reactor_client_ksipredictor_inputupdate_ks_reactor_ksinput"></a>

Called when a new frame of input is generated. Only called for entities with player controllers.

```csharp
void InputUpdate(ksInput input)
```

#### Parameters

`input` [ksInput](/reactor/api-reference/ks.reactor/ks.reactor.ksinput.md)

Input

### IsPredictedProperty(uint) <a href="#ks_reactor_client_ksipredictor_ispredictedproperty_system_uint32" id="ks_reactor_client_ksipredictor_ispredictedproperty_system_uint32"></a>

Does the predictor predict the property value with the given `propertyId`?

```csharp
bool IsPredictedProperty(uint propertyId)
```

#### Parameters

`propertyId` [uint](https://learn.microsoft.com/dotnet/api/system.uint32)

Property id

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the predictor predicts the property value.

### ParentChange(ksBaseEntity, ksBaseEntity) <a href="#ks_reactor_client_ksipredictor_parentchange_ks_reactor_client_ksbaseentity_ks_reactor_client_ksbasee" id="ks_reactor_client_ksipredictor_parentchange_ks_reactor_client_ksbaseentity_ks_reactor_client_ksbasee"></a>

Invoked when the Entity parent changes. This method should correct predicted values by converting the positions back to world positions for the removal of the old parent and then to the local position for the new parent.

```csharp
void ParentChange(ksBaseEntity oldParent, ksBaseEntity newParent)
```

#### Parameters

`oldParent` [ksBaseEntity](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md)

Parent entity being removed.

`newParent` [ksBaseEntity](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksbaseentity.md)

Parent entity being added.

### ServerUpdate(ksReadOnlyTransformState, Dictionary\<uint, ksMultiType>, bool, bool) <a href="#ks_reactor_client_ksipredictor_serverupdate_ks_reactor_ksreadonlytransformstate_system_collections_g" id="ks_reactor_client_ksipredictor_serverupdate_ks_reactor_ksreadonlytransformstate_system_collections_g"></a>

Called once per server frame.

```csharp
bool ServerUpdate(ksReadOnlyTransformState state, Dictionary<uint, ksMultiType> properties, bool teleport, bool idle)
```

#### Parameters

`state` [ksReadOnlyTransformState](/reactor/api-reference/ks.reactor/ks.reactor.ksreadonlytransformstate.md)

Server transform data. Null if not smoothing a transform.

`properties` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2)<[uint](https://learn.microsoft.com/dotnet/api/system.uint32), [ksMultiType](/reactor/api-reference/ks.reactor/ks.reactor.ksmultitype.md)>

Smoothed properties whose values changed since the last frame. Null if no properties have changed.

`teleport` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Did the entity teleport?

`idle` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if there were no transform or property changes since the last frame.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false and `idle` is true, this function will not be called again until the server transform or a server property changes.
