I’m working on a script here to spawn cat’s and then move them, why do we use the * operator when we are trying to change the angle, Wouldn’t it make sense to use the addition operator?
spawn cats and then it move them where?
I should have been more specific, I need help understanding why we use the * for changing direction, rotation etc. Why don’t we use the + operator, what’s the difference between using the + operator or the * operator.
tell me, the script is not working?
It’s working I need help understanding why we need to use the * operator instead of the +.
Because ( * ) mean “multiplication”
try to change the ( * ) with a (+) and see the difference
So here’s why your doing it so your getting the catmesh’s cframe and then multiplying it a rotation
Yes, but why multiplication, I thought adding 45 to the frame rotation made sense but we multiply it for some reason.
That’s just how cframe works. Pretend your doing 3x2 your getting 3 and then adding it 2 times
I dont know That’s how CFrame work
Oh, so it’s just a formatting thing, thanks guys.
Because you’re not really adding angles or adding to the position components. When you use arithmetic on CFrames you’re performing matrix operations.
That’s not the answer dont go thinking that
CFrames are not numbers and the +, *, / etc. operators can be overloaded in whatever ways the creator of the API thinks is most fit.
When you do CFrame1 * CFrame2
, you aren’t multiplying the CFrames. You are calling a method of the first CFrame with the second CFrame.
When you do Vector3 + Vector3
, you aren’t adding the vectors. You are calling a method that’s something like
function Vector3:__add(other)
return Vector3.new(
self.X + other.X,
self.Y + other.Y,
self.Z + other.Z
)
end
The creator of the API could’ve made Vector3 multiplication do Vector3:Dot(Vector3), as the dot product is sometimes considered vector multiplication. But in ROBLOX, that multiplies each value.
You can make any table give a weird result (instead of erroring) when adding, multiplying etc. using metatables.
tl;dr It is that way because it was decided it would be that way nearly two decades ago