Log inGet started
Package

PositionConstraint.component

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

PositionConstraint

Constrains an entity's transform (position, optionally rotation and scale) to follow a target entity, with optional offset. Use weight to control smoothing.

Public fields: targetEntityId, targetPositionX/Y/Z, offsetX/Y/Z, axisX, axisY, axisZ, weight, constrainRotation, constrainScale.

targetEntityId names the entity to follow: write the entity, its id or its name, and it reads back as the entity; a name is found when the constraint is applied. It is an entity reference, so a constraint a scene's build.luau writes between two entities the build spawns (targetEntityId = target or targetEntityId = target.id) names the entity the build placed, through every rebuild, save, load and play.

Methods: setTarget(entityId), setOffset(x, y, z), setWeight(w).

entity(id).component.add("PositionConstraint", {
    targetEntityId = entity.find("car"),
    offset = {0, 5, 10},
    weight = 0.15,
})