Tweens, Lerps or animations?

Hey :wave:

I am wanting to make a theme park game on Roblox. Before I start, I want to do some testing. I want the rides to be as smooth as possible on all platforms, like in the game Theme Park Tycoon 2.

What do you think is best to make ride cycles and keep them smooth and reliable?

I guess for the coasters it will have to be a node system? I have spoken to some developers and they say to make their roller coasters, they “simulate on server and client with the server being more authoritative and the clients constantly adjusting to match it”. I have placed that in quotes as that is just what the developer had said in message, and I only have a small idea what he means?

For the flat rides (like drop rides, and spinning ones), is it better to use animations?

Any information at all will be appreciated :slight_smile:

Cheers

Might help you out:

1 Like

I wouldn’t say it’s a good idea to use one for everything, but a mixture should do well. Use tweens to move the seats around the rollercoasters themselves because they provide more control over the animations and you can use things like linear interpolation within it (if you don’t need any particular control over it) using Enum.EasingStyle.Linear.

For elements you do need more control over, for example getting a specific alpha necessary to a certain part of the coaster, you should use linear interpolation for that bit. If you need it to match with a specific EasingStyle and EasingDirection, you can use TweenService:GetValue().

For the coasters themselves, you would need some kind of pathfinding system (like how you suggested a node system).

I think animations should only really be used for the guests in the rides. It’d be hard to keep the guest animations correctly linked up to the ride, but I think it’d just be easier to use tweens and lerping at the time instead of creating animations for each ride. You can use things like welds to keep the guests attatched to the rides and just animate them from there.

In summary: Use a combination of interpolation methods with tweens for your rides.

1 Like

This video will show you the performance differences between Animations, tweens and physics


This video will show you how to sync parts between clients without using any network data by using getservertimenow()

I think something on these lines would be a good way for you to sync roller coasters without relaying on the server

1 Like

Hello.

I have just watched your tutorials and found them really interesting and helpful. I actually watched your “Optimizing Tweening” video a while ago which lead me to ask if tweens would be the best to use for my rides. After testing, they work great, especially the local tweening, but one big thing lets them down. The fact that I cannot do two tweens at once on a model, for example swing and spin seats.

I have spoken to another developer that has worked on games where balls follow a track, like a waterslide or a roller coaster, but I believe he uses physics but also prerenders them on the server and plays it on the client to reduce lag. Don’t quote me on that, as it was quite confusing and I cannot really remember. Is this a valid approach to making rides?

I have also tried out using RunService with CFrame manipulation. I just really don’t know what the best option is to make these types of things.

If you could assist me in any way / help me to find out which is the best option, it would be greatly appreciated

Thanks :slight_smile:

In this video we pre compute a array of cframes then use that to move the npcs along the path you can adjust the spacing of the cframes to effect the speed and you can use the Y position offset to know when to speed up or slow down and also have a drag/friction formula to stop it going to fast

here is some pseudo code

local speed = 1 -- start with a small speed just to get us moving
local drag = 0.01
local gravity = 1

local currentNode = node.new(part01)
local nextNode = node.new(part02)
local position = part01.Position

local positions = {position} -- use cFrames here to save the rotation but this demo will only save positions

while nextNode do
    while positionIsNotCloseToNextNode do
        local distance = speed -- we use distance to normalize the step
        local stepVector = (nextNode.Position - position).unit * distance -- this is also the direction the cart needs to face in when you generate your cframe

        speed -= stepVector.Y * gravity * distance
        if currentNode.Boost then speed += currentNode.Boost * distance end
        speed -= speed ^ 2 * drag * distance

        if speed <= 0 then error("Track failed to get to the end") end

        position += stepVector
        table.insert(positions, position)
    end
    currentNode = nextNode
    nextNode = node.new(nextPart) else nil
end

print(positions)

or you can do it the way the person you spoke to did it play it with physics and every frame save the cframe into a array