Tank convenyor sytem

As I was looking around at how to make an easy conveyor part, and I always wanted to recreate the wii tank game, I came to the conclusion that making the tank belts a conveyor part would be the most realistic. Making the conveyor using this article was not the problem.

I have a tank model and welded the belt’s to the hull with weld constraints like so:
image
with the tank as of right now looking like this:
image
However moving the tank forward and backward isn’t an issue, the issue I’m trying to resolve is how to rotate it. As I’m trying to make 1 conveyor with positive (5) speed (velocity) and the other one negative (-5) I thought it would rotate the tank by itself, however, it doesn’t do that, it chooses 1 of the directions, forward or backward, but does not change the rotation of the tank.


I have tried making the parts massless and making the speed at which the conveyors move higher and lower, but did not get what I was expecting.

I used the following code from the article but I slightly edited it to work for the demonstration used in the video. This is the script that is inside both belts.
image

local conveyor = script.Parent

local attStart = conveyor:FindFirstChild("AttStart")
local attEnd = conveyor:FindFirstChild("AttEnd")

local function setVelocity()
	local direction = attEnd.WorldPosition - attStart.WorldPosition

	local conveyorVelocity = direction.Unit * conveyor:GetAttribute("ConveyorSpeed")
	conveyor.AssemblyLinearVelocity = conveyorVelocity
end

conveyor:GetAttributeChangedSignal("ConveyorSpeed"):Connect(setVelocity)
conveyor:GetPropertyChangedSignal("Orientation"):Connect(setVelocity)

while conveyor:GetAttribute("ConveyorSpeed") ~= 0 do
	wait(0.1)
	setVelocity()
end

edit: as in the article, attributes added to the conveyor belts have opposite values:
left belt:
image
right belt:
image
what it would represent:

3 Likes

Try SurfaceAppearance or Beam

how would this affect physics?

It won’t affect physics, so no problem

I need it to improove something at least…
I’m not trying to decorate the tank

The problem is the weld constraints, they make the parts count as “One assembly” as “one rigid body” so the assembly linear velocity is not per part but per the entire assembly

One method is to try a physics constraint to try to connect the parts together but not “rigidly” perhaps? I never tried this.

Otherwise you can try using a body angular velocity which does tank turning functionality simplistically. I did something similar with a rideable NPC in order to do tank controls for my mech.

I’m making a rotation script with an angular velocity depending on the conveyor speed of both belts together to make the hull rotate.
image
which looks like this right now:

local t = script.Parent.Parent
local a = t:FindFirstChild('Body'):FindFirstChild('AngularVelocity')

while wait(0.1) do
	local left = t:FindFirstChild('Rups_Left'):GetAttribute("ConveyorSpeed")
	local right = t:FindFirstChild('Rups_Right'):GetAttribute("ConveyorSpeed")
	las = (-1*left)
	ras = (1*right)
	print(las,ras)
	if ras>las then
		res = ras 
	else
		res = las
	end
	a.AngularVelocity = Vector3.new(nil,res,nil)
end

it does rotate, but not entirely depending on the conveyor speed yet.
forgive me if this code isn’t readable as I’m just trying to evaluate.

edit: code worked

1 Like