I’m trying to make a monkey swinging effect using dot products.
I’m currently using the right vector of the swing part and the lookvector of player and multiplying that to get my dot product.
Further details
self.Angles = {
[1] = CFrame.Angles(0,math.rad(180),0),
[2] = CFrame.Angles(0,0,0)
}
local vector1 = self.Swing.CFrame.LookVector
local vector2 = self.Root.CFrame.LookVector
local product = vector1:Dot(vector2)
if product < 0 then
self.Attachment1.CFrame = self.Angles[1]
else
local randomAngle = self.Angles[math.random(1,2)]
self.Attachment1.CFrame = randomAngle
end
In the code snippet you can see I’m using a product to move an attachment at a certain angle or random angle.
The attachments are part of a hinge constraint which I am using to create my monkey swinging effect.
The problem is also very inconsistent and only happens sometimes.