Ok, I’m going to be completely frank here. You need to have mathematical awareness in order to program these kind of stuff. Ie to know how math works and how to use math to do what you want to do.
Main question is:
What does multiplication and addition do? And how do they relate to each other?
After you know the answer to that fundamental question, coming up with equations is actually a piece of cake for most of what you need in programming general stuff in game.
But you don’t just need equations to turn a character’s head. You need to learn about matrices, linear transformations, interpolations, quaternions.
Another thing is there is no;
This is a wrong way to look at math and equations within. There is no equation that you need to fit in order to make a formula. You wouldn’t be making a formula there, you’d be using one. There isn’t a list of formulas that you need to know to come up with one that works for your situation.
Someone on discord asked how he could relate a random number with the price. The higher the price, the lower it should appear so a lower number. He said he wasn’t good with math and that what he was coming up with was complex. This was actually a very easy solution.
math.random()/price
This is the main idea. If you’re relating two things, you don’t need complex math as they can relate easily like this. But let’s say this doesn’t quite give you the curve that you want for your game. You want the randomness to drastically drop as price goes higher. We can use another type of relation, powers. You can take the power of price (^2, ^3 etc.) and the graph in which the area that the randomness has will get smaller at a much higher rate. After this is easy, you have your random number that scales with the price however you want and you can do whatever you want with the new number.
Now I’ll start explaining a bit about the question I asked:
What does multiplication and addition do? And how do they relate to each other?
Think of a formula as a bread recipe. It needs flour, milk and eggs. But does it need all of them? That gives us a cake dough, we don’t want a cake. We want a bread dough. So we add flour and water maybe salt, yeast and oil.
bread_dough = flour + water
But is this all there is to make a dough? What is the unit of the dough? How much flour and water do I add? Now here, you need to know PHYSICS. What is your unit of measurement? Is it grams or milliliters? Is this thing scalar or is it a vector? Is this flour a matrix or an angle? We all know it’s supposed to be in grams it’s mass of something. (screw you imperial users) Ok but can you add a mass and a volume together? No. How would the unit of something like that change? That never happens. In physics and math, you don’t add things with different units together 99% of the time and you most definitely don’t in any practical situation in Roblox. So whatever we add, must have the same unit.
Now how much do we want of these things since it’s in grams? Do we add just one gram of both? No we are not making bread for ants.
bread_dough = x*flour + y*water
Oh great now we have some bread but it doesn’t taste that good. We should add some salt in it. But we have some amount of salt that we have to use no matter what and we have to scale our dough amount with that salt. We know the perfect bread needs 1000 grams of flour, 100 grams of water and 10 grams of salt. Since we have to use all of that salt because it’s what we’re supposed to base it off of. We need to come up with 1000 grams of something somehow:
salt = something
x = salt.mass*100
y = salt.mass*10
z = salt.mass*1
bread_dough = x*flour + y*water + z*salt
Now let’s get back to units. We said that when you multiply two things, the unit of it changes. But what if what we have is unitless? Let’s start by explaining what the unit of flour / water / salt is: We wanted to add grams together right? So what kind of a unit does that flour thing have if x / y / z is already mass? Actually, x, y and z don’t have any unit. Inherently they represent the grams. But what we take is the quantity of mass. Such that it is a relation of how many grams are there in it, not the grams itself.
Here we’ve created a formula for something. So how does this relate to anything in programming? If you know about the mathematical expressions, it all only boils down to how x and y must relate to each other. You have to ask yourself what is the relation between (in your situation with heads and camera) where the head looks and where your camera looks. Well we both know that orientations are defined with CFrames in Roblox which is actually just a matrix. In this case you would need to learn matrices and how to manipulate them. Now most of the boring math is done with the functions Roblox provides so learning what they are used for is enough. You don’t really need to know intricate ways “the CFrame math” works. BUT do learn everything you can about Vectors and what they are useful for, that is very important. Trigonometry is also something quite important. Learn what Tangent, Cosine and Sine functions do and how they relate.