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.
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)
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
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