Help making parts go faster in certain directions

Hey everybuilder!

I want to make a game similar to the title “Chess for Idiots” in Roblox, and I wanted to give bishops and rooks a boost to movement when going in a certain direction relative to their orientation. However, I’m not entirely sure how to do this easily without doing a tedious amount of scripting. I’ve skimmed the different classes but I havent found anything yet due to how much stuff there is. If this isn’t possible to do with a physics object due to how niche of a problem this is, can somebody point me in the right direction for creating something like this?

Below is a simple diagram of what I want to achieve.
image

You can check out this tutorial, you can use Vector3:Dot to calculate the similarity between 2 CFrames angles

image

And then you can multiply the returned value by the speed

1 Like

After a bit of tinkering, I managed to produce this script. It doesn’t quite print the correct thing, however, and I’m all out of ideas. Help!!!

Also, thanks for responding so quickly!

local Part = script.Parent
game["Run Service"].Heartbeat:Connect(function()
	local OffsetPos = Part.Position + Part.AssemblyLinearVelocity
	local moveDir = (Part.Position - OffsetPos).Unit
	print(moveDir)
	local compare = Part.Orientation:Dot(moveDir)
	print(compare)
end)
1 Like
local RunService = game["Run Service"]

RunService.Stepped:Connect(function()
	local direction = Vector3.xAxis 
	local lookVector = script.Parent.CFrame.LookVector
	
	local dotProduct = direction:Dot(lookVector)
	print(dotProduct + 1)
	
end)

The dotproduct should be 2 when facing the correct direction, and 0 when facing the complete opposite direction

1 Like

Thank you so much for the help and responding so quickly!

1 Like

Oh, one more thing: why use “Stepped” instead of “Heartbeat” and is it better?

I think heartbeat runs after the physics simulation is completed and stepped runs before calculating the next frames physics. There should be no difference in your code, you can use any of them

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