Problem with applying velocities

i am currently messing around with some water physics for a game i am working on. i have already calculated the force that should be applied to the parts in the water, but i am having trouble applying that to the parts velocity.

i am not sure about inserting linear velocities, because that would mean more than 4000 of them existing for some (quite often) scenarios in the game.

there are 0 ways to decrease the instance count because my project is a vehicle sandbox and players enjoy putting in small details that take up a lot.

this is my code that attempted to apply the force directly into the velocity of the part, but that sent me to space because (of course), updating the y value in the velocity every game heartbeat is a very bad idea

here is the code that edits the velocity of every single part. v[1] is the part itself, and v[2] is the calculated velocity.

	for i, v in pairs(targetBlocks) do
		local ray = castRay(v[1])
		if ray and ray.Instance then
			v[1].AssemblyLinearVelocity = Vector3.new(v[1].AssemblyLinearVelocity.X,v[2],v[1].AssemblyLinearVelocity.Z)
		end
	end
1 Like