follow(obj: GameObj | null, offset?: Vec2): FollowComp
Follow another game obj's position.
paramobj- The game obj to follow.
paramoffset- The offset to follow at.
const bean = add(...)
add([
sprite("bag"),
pos(),
follow(bean) // Follow bean's position
]);
// Using offset
const target = add(...)
const mark = add([
sprite("mark"),
pos(),
follow(target, vec2(32, 32)) // Follow target's position with an offset
])
mark.follow.offset = vec2(64, 64) // Change the offset
returnsThe follow comp.
sincev2000.0
groupComponents