# Physics Systems Help

I know this may probably be asking for a lot, but I’m having trouble with implementing physics systems.

A bit of backstory, basically I’m making a custom engine within Roblox and it obviously needs to run physics (don’t try to talk me out of doing this). And to give a brief explanation of the issue, because I am unsure whether I’m using the correct terminology, I have a problem where I want an object to move relative to another object. A lot of literature on physics engines are often hard for me to digest, due to their complexity or using languages that I have trouble interpreting into Luau, translating them, and then using those ideas in my systems, etc.

For example, a player stands on a boat, the player should move and rotate according to the boat’s movement. A moving object collides with and pushes the player, keeping it at the end where the player is being pushed relative to the movement of the pushing object.

In my engine, I am using components to store data and create behavior. So, I am having issues finding a way of determining what objects should “inherit” forces from other objects.

For the boat example, should I always just find what the player is standing on? What if I want them to still be “locked” to the boat if they’re jumping?

For the pusher example, should it just be based off of objects that are colliding with the player that are moving/have forces?

I don’t know how to integrate those two problems (and similar) into a singular system. Any help with ideas is appreciated, thank you.

6 Likes

Well, if you can determine which parts are touching the player, you can set the player’s velocity to the part’s velocity. Touching parts should effectively inherit velocity.

I’m assuming you’ve gotten collision all figured out.

2 Likes

If you can make a custom character controller then you can do the thing you’re talking about with boats.

2 Likes

Collision, yes.

My concern was if like there was a hierarchy of things. For the boat example, what if there was a box on the boat that moves around, but the player was standing on the box. How would I know to update the box first and then the player? Would I have some node-based system for that?

In that case, I think the easiest solution would be to update everything twice because you cannot be sure whether it has been updated.

I don’t know if I’m overthinking too much, but what about with cases of 3 or more objects that “inherit”? Should I just have a built in limit because I (probably) won’t have anything that complicated? Or should I have some recursive type thing for that?

(I’m just trying to brainstorm ideas so you don’t have to answer all that)

I thought about recursion, but it’d be a bit inefficient because I’d have to go down the tree to find the end, and then back through it to keep adding all the inherited velocities.

Probably. You’d have to run it twice unless you could somehow do all of this at the exact same time.

Physics inheritance should be as simple as things like welds that inherit the velocity of their root part. I don’t know of any physics system that has ever used inheritance for touching objects.

1 Like

cant you just work from bottom to up by iterating trough your objects based on the Y Position. then for each object that you update you detect if it’s standing on top of an item and do your gimmicks

Probably best to not have it based on it’s Y position but rather actually what is really on what. Like having something define that “Box is on top of boat”.

This, like the pusher example, it won’t strictly be object on top of object, so Y values wouldn’t work.

You could probably use the force that always attracts the player to one position whenever they jump.(I think it was bodyforce). You could set up a script where it checks if the player is jumping or not

You are. Start with the simplest version of what you’re thinking and go from there. You can’t reasonably know what features you will need before you know what you currently have.

1 Like