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:
with the tank as of right now looking like this:
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.
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:
right belt:
what it would represent: