@rbxts/jecs-assemblies
v1.0.2-ts.1
Published
Utility for calculating cframe offset chains for Jecs.
Downloads
163
Readme
Jecs Assemblies
Utility for calculating cframe offset chains for Jecs.
Setup
Replace
transform,relative, andpivotwith your own components. This is optional, and components will be created if they don't exist when callingjecs_assemblies.world.Call
jecs_assemblies.world(world)before using it to set it up with your world.Add
jecs_assemblies.system()to your systems. Set the order right before your transform cframes apply.
local c = require(components)
local jecs_assemblies = require(jecs_assemblies)
jecs_assemblies.transform = c.transform
jecs_assemblies.world(world)
return {
system = function()
jecs_assemblies.system()
end
}Usage
- Use
jecs_assemblies.pivotas a pair to reference a parent entity. - Use
jecs_assemblies.relativeto set a relative CFrame to the parent. - Transforms will be applied to
jecs_assemblies.transform. The very first parent will use the value ofjecs_assemblies.transform. - You can chain multiple pivots to get a final transform.
local c = require(components)
local ja = require(jecs_assemblies)
local character = world:entity()
local camera = world:entity()
world:set(character, c.transform, cf)
world:add(camera, pair(ja.pivot, character))
world:set(camera, c.relative, rel)
-- camera transform = character transform * camera relSwapping pivots
- use
jecs_assemblies.swap_pivotto swap the pivot of an entity. This will change your pivot while keeping the world space transform by calculating the relative cframe from the current entity transform and the new pivot transform. This function will also remove any previous pivots.
