Surface-relative gravity using world gravity?

Hi! I’m currently working on a droplet simulation effect. The droplets drip down the parts surface with gravity.

This works perfectly when using the front of the part (Enum.NormalId.Front)! The droplets properly flow down the surface, while respecting the cframe of the part:


However, when using other faces, things begin to fall apart. Here I’m using the left face of the part (Enum.NormalId.Left), and you’ll notice the droplets aren’t moving with the world gravity anymore:

How can I fix this? The “GravityVector” should be a Vector3 with just the XY representing the surface-relative force to move with world gravity.

Here’s a modified snippet of my code:

...
local NormalId = Enum.NormalId.Left
local Normal = Vector3.FromNormalId(NormalId)
	
local WorldGravity = Vector3.new(0, -5, 0) * DeltaTime
local GravityVector = PartCFrame:VectorToObjectSpace(WorldGravity) -- Force relative to the surface
...
-- Later on
local NewLocalPosition = Droplet.LocalPosition + GravityVector

Figured it out:

image
image

VV this returns Axis1 and Axis2, but this only needs to be done once so I cache it (I know it could just be a table, ill convert it to one at some point)
image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.