> 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.kslinearpredictor.md).

# Class ksLinearPredictor

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

Smooths/predicts movement using linear interpolation and extrapolation.

```csharp
public class ksLinearPredictor : ksIPredictor
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksLinearPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.kslinearpredictor.md)

#### Implements

[ksIPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksipredictor.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Properties

### Config <a href="#ks_reactor_client_kslinearpredictor_config" id="ks_reactor_client_kslinearpredictor_config"></a>

Configurable data for customizing the the predictor. Returns null if the predictor is using the [Default](/reactor/api-reference/ks.reactor.client/ks.reactor.client.kslinearpredictor/ks.reactor.client.kslinearpredictor.configdata.md#KS_Reactor_Client_ksLinearPredictor_ConfigData_Default). Assign this if you want to override the defaults.

```csharp
public ksLinearPredictor.ConfigData Config { get; set; }
```

#### Property Value

[ksLinearPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.kslinearpredictor.md).[ConfigData](/reactor/api-reference/ks.reactor.client/ks.reactor.client.kslinearpredictor/ks.reactor.client.kslinearpredictor.configdata.md)

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

Always false; the linear predictor does not require a player controller.

```csharp
public 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_kslinearpredictor_clientupdate_ks_reactor_kstransformstate_system_collections_gene" id="ks_reactor_client_kslinearpredictor_clientupdate_ks_reactor_kstransformstate_system_collections_gene"></a>

Updates the client transform and properties.

```csharp
public 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.

### Create() <a href="#ks_reactor_client_kslinearpredictor_create" id="ks_reactor_client_kslinearpredictor_create"></a>

Gets a predictor instance from the pool, or creates one if the pool is empty.

```csharp
public static ksLinearPredictor Create()
```

#### Returns

[ksLinearPredictor](/reactor/api-reference/ks.reactor.client/ks.reactor.client.kslinearpredictor.md)

Predictor instance

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

Resets member variables and returns the predictor to its object pool.

```csharp
public void Detached()
```

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

Called when the predictor is disabled. May be called multiple times. Called before [Detached](#KS_Reactor_Client_ksLinearPredictor_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
public void Disabled()
```

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

Called when the predictor is enabled. May be called zero or more times. Called after [Initialize](#KS_Reactor_Client_ksLinearPredictor_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
public void Enabled()
```

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

Initializes the predictor.

```csharp
public 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_kslinearpredictor_inputupdate_ks_reactor_ksinput" id="ks_reactor_client_kslinearpredictor_inputupdate_ks_reactor_ksinput"></a>

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

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

#### Parameters

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

Input

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

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

```csharp
public 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.

### OwnershipChange(uint, uint, ksOwnerPermissions, ksOwnerPermissions) <a href="#ks_reactor_client_kslinearpredictor_ownershipchange_system_uint32_system_uint32_ks_reactor_ksownerpe" id="ks_reactor_client_kslinearpredictor_ownershipchange_system_uint32_system_uint32_ks_reactor_ksownerpe"></a>

Called when the entity's owner or owner permissions change. If the transform owner changed, changes the time keeper to the new owner's time keeper and resets the prediction state.

```csharp
public void OwnershipChange(uint oldOwner, uint newOwner, ksOwnerPermissions oldPermissions, ksOwnerPermissions newPermissions)
```

#### Parameters

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

Player id of the old owner

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

Player id of the new owner

`oldPermissions` [ksOwnerPermissions](/reactor/api-reference/ks.reactor/ks.reactor.ksownerpermissions.md)

Old owner permissions

`newPermissions` [ksOwnerPermissions](/reactor/api-reference/ks.reactor/ks.reactor.ksownerpermissions.md)

New owner permissions

### ParentChange(ksBaseEntity, ksBaseEntity) <a href="#ks_reactor_client_kslinearpredictor_parentchange_ks_reactor_client_ksbaseentity_ks_reactor_client_ks" id="ks_reactor_client_kslinearpredictor_parentchange_ks_reactor_client_ksbaseentity_ks_reactor_client_ks"></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
public 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_kslinearpredictor_serverupdate_ks_reactor_ksreadonlytransformstate_system_collecti" id="ks_reactor_client_kslinearpredictor_serverupdate_ks_reactor_ksreadonlytransformstate_system_collecti"></a>

Called once per server frame.

```csharp
public 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.
