Ravenfield

Ravenfield

Movement Core
RadioactiveJellyfish  [developer] 20 Jul, 2023 @ 7:49am
For Scripters
Movement Core is essentially a solution for all the times multiple scripts change an actor's speed and completely override each other's settings.

Accessing Movement Core
First, to access Movement Core just put this in your Start function:
local movementCoreObj = self.gameObject.Find("MovementCore") if movementCoreObj then self.movementCore = movementCoreObj .GetComponent(ScriptedBehaviour).self end
IMPORTANT: Do not put this in Awake. It has to be in Start!

Add Modifier
The AddModifier function lets you add a multiplier to the actor's speed.

Given the code above, to add a modifier do:
self.movementCore:AddModifier(targetActor,"MyModifierName",modifier)

All modifiers are multiplied together to get the final speed multipler for the actor. For example, if I have the modifier "WSWeight" with a value of 0.8 and "ADSPenalty" with a value of 0.5 and given a base speed multiplier of 1 my final speed will be calculated as such:
1 x 0.8 x 0.5 = 0.4

Make sure your modifier name is unique! Only one instance of a modifier can exist at a time on an actor. If a modifier already exists for the actor, it will simply overwrite the existing modifier with the new one.

Remove Modifier
The RemoveModifier function removes a specific modifier from the actor.

Given the code above, to remove a modifier do:
self.movementCore:RemoveModifier(targetActor, "MyModifierName")

Other Things To Note!
Every time a modifier is added or removed, the system will recalculate an actor's final speed. Remember this! It's best to only change modifiers when you absolutely need to.

All modifiers are also removed on death! So an actor will be fresh on respawn. As of 1.0.3 Movement Core no longer removes modifiers on death!

The Weight System uses these two modifiers: "WSWeight" and "ADSPenalty"

If you have any questions, feel free to reach out to me in the main RF Discord or on my own server.
Last edited by RadioactiveJellyfish; 11 Jan, 2024 @ 6:11am