R
roblox-ts3mo ago
duck

using relationships with tweening

@PepeElToro41
12 Replies
duck
duckOP3mo ago
@PepeElToro41 if I use start and goal comopnent, how can I ensure that start and goal is a cframe, not a number. I don't want something like StartCframe, EndCframe component, that makes it very verbose
PepeElToro41
PepeElToro413mo ago
I think its fine to name it startCFrame or something, or interpolationstart and interpolationgoal if you separate the start and goal from the interpolation itself it makes easier to replicate for example because the server can have the start and goal, but not the tween so the client can then create the tween this also makes it easier to query all interpolators with query(start, goal, transform) so this would query all interpolators then you could use things like pairs or whatever to define the behavior for each interpolation you could also pack the start and goal in an interface if you dont want that many components
interface InterpolationInfo {
Start: CFrame,
Goal: CFrame,
Alpha: number
}
interface InterpolationInfo {
Start: CFrame,
Goal: CFrame,
Alpha: number
}
duck
duckOP3mo ago
i personally think otherwise. I don’t want to make systems only deal with cframe interpolation and another system dealing with number interpolation. My idea is to make a universal system that applies motion goals using ripple.
PepeElToro41
PepeElToro413mo ago
then you could use an interpolation info
duck
duckOP3mo ago
I personally use my component based replication and I dont really have problems dealing with component or pair replication
PepeElToro41
PepeElToro413mo ago
with a generic
duck
duckOP3mo ago
i am proud 😎 so in interpolation info, I just store if its tween, linear, or spring. Then I store the start and goal there and query it?
PepeElToro41
PepeElToro413mo ago
yeah, for normalization because they all have common values
duck
duckOP3mo ago
pretty sure thats what I did? idk tbh
PepeElToro41
PepeElToro413mo ago
you save the goal in the tween component
No description
PepeElToro41
PepeElToro413mo ago
ideally it should be normalized I mean I dont think its a big deal
duck
duckOP3mo ago
ye thats fair
for (const [entity, start, goal] of handle
.query(
pair(components.NetworkedStartPair, Wildcard),
pair(components.NetworkedGoalPair, Wildcard),
components.NetworkedSpringOptions,
)
.without(components.MotionObject)) {
const startComponent = handle.target(entity, components.NetworkedStartPair);
const goalComponent = handle.target(entity, components.NetworkedGoalPair);

if (startComponent === goalComponent && start && goal) {
const motionObject = createMotion<defined>(start as defined);
motionObject.spring(goal);
handle.set(entity, components.MotionObject, motionObject);
}
}
for (const [entity, start, goal] of handle
.query(
pair(components.NetworkedStartPair, Wildcard),
pair(components.NetworkedGoalPair, Wildcard),
components.NetworkedSpringOptions,
)
.without(components.MotionObject)) {
const startComponent = handle.target(entity, components.NetworkedStartPair);
const goalComponent = handle.target(entity, components.NetworkedGoalPair);

if (startComponent === goalComponent && start && goal) {
const motionObject = createMotion<defined>(start as defined);
motionObject.spring(goal);
handle.set(entity, components.MotionObject, motionObject);
}
}
I did something liek this

Did you find this page helpful?