How do you come up with complicated functions ?

IceboxIcebox Member Posts: 1,485

These rules were taken from a youtube tutorial by Ash Jakcson to make a spining ledge.

Actor has 6 real self attributes and 1 angle attribute :

1- core x (real)
2- core y (real)
3- goal x (real)
4- goal y (real)
5- Distance from core (real)
6- move speed (real)
7- starting offset ( angle)

there are 2 change attributes and 4 constrain attributes:

1- change attribute self.core x to self.position x
2- change attribute self.core y to self.position y

3-constrain atrib self.goal x to self.distancefromcore * cos(self.startingoffset + self.time * self.movespeed %360)+self.corex
4-constrain atrib self.goal y to self.distancefromcore * sin(self.startingoffset + self.time * self.movespeed %360)+self.corey

5- constrain movement velocity x to 5(self.goal x - self.position x)
6- constrain movement velocity y to 5
(self.goal y - self.position y)

This works perfect , the result is a spinning ledge but I put these rules to explain my problem:

1- I really don't understand why use cos/sin/self.time and this " %360 "
2- Why use " * " at some places and " + " on others
3- Why are attributes in and out of brackets.

This annoys me alot , if there wasnt a tutorial on this I would never be able to come up with these functions by myself. I noticed there are really smart people in the forum that know and understand how to use functions to make anything they want. I am trying to educate myself but im always limited when it comes to functions , even if I read the guide from GS , Do I need to take math lessons ? or is this the type of thing that comes with experience and testing? any tips?

Thank you :)

Comments

  • pHghostpHghost London, UKMember Posts: 2,342

    @Icebox1910 said:
    Do I need to take math lessons?

    I would highly suggest them, yes. All of this is just mathematics. The functions and formulas are pure universal math, nothing specifically to do with GameSalad.

  • IceboxIcebox Member Posts: 1,485

    @pHghost Thank you for replying but when I saw multiplying self.time with move speed that got me thinking that it might not be just math

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @Icebox1910 said:
    pHghost Thank you for replying but when I saw multiplying self.time with move speed that got me thinking that it might not be just math

    Self.time is used for the angle that cos and sin operate on simply out of convenience, people just want things to rotate at useful speeds, self.time is measured in seconds, if cos and sin are looking at self.time for their angle, then it will take 10 seconds to rotate by 10 degrees, very very slow ! Or it will take 6 minutes (360 seconds) to rotate 360 degrees . . . not much use in a game, so people tend to multiply the game.time by some other factor, for example if you make an attribute called 'speed' and set that value at 100, then use game.time * game.speed as the angle that cos and sin operate on then it is 100 times faster than sitting around waiting for game.time to amass enough value to rotate an object through one single rotation.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @Icebox1910 said:

    P.S, as to the idea of 'How do you come up with complicated functions ?' I'd say 'don't' ! I spend all my time trying to make functions as uncomplicated as possible, simple functions are easier to process, tend to run faster and are less involved to fix and work with. I much prefer a clever short expression (stolen from RThurman) that gets the job done rather than a 50 page sprawling and complicated equation. K.I.S.S ! :smile:

  • IceboxIcebox Member Posts: 1,485

    @Socks I'll sure keep that in mind but sometimes things can't be done without messed up functions :D and thanks for explaining the time thing it was confusing me ! o:)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Yes all functions are math based or strings. Strings are the assembly of data aka text et... It's not voodoo...lol study vector math online this is the most common math we do on here. Sin, cos are basic vector functions. I studied this in my electrical education and it is complex, heck I'm still no good at it..lol asymptotic of my dyslexia. Most people don't know math comprehension is a symptom of dyslexia. It sucks!! But I have @socks and @RThurman as my crutches! They are always kind enough to help me out when i need it.

  • tmanntmann Member Posts: 278

    Just to be clear sin and cos are trigonometric functions.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @Icebox1910 said:
    Socks I'll sure keep that in mind but sometimes things can't be done without messed up functions :D and thanks for explaining the time thing it was confusing me ! o:)

    They only look messed up ! Usually complicated looking functions/equations are just a bunch of very simple ideas strung together !

    . . . . . . . . . . .

    Attached is a cos/sin 'ruler' the help you understand it a little better, grab the small white circle that is touching the edge of the large outer circle and drag it around, the red line is showing you the cos of whatever angle you dragged the angle indictor to, the yellow line shows you the sin.

    . . . . . . . . . . .

    "Why are attributes in and out of brackets"

    Look at these two equations . . .

    10 x 4 + 4 = 44

    10 x 4 + 4 = 80

    . . . which is correct ? Both !

    (10 x 4) + 4 = 44

    10 x (4 + 4) = 80

    In maths things within brackets are calculated first, without brackets the sum 10 x 4 + 4 could be either 44 or 80, we'd have no real way of knowing which.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited July 2015

    @tmann said:
    Just to be clear sin and cos are trigonometric functions.

    Trigonometry (from Greek trigōnon, "triangle" and metron, "measure") is a branch of mathematics that studies relationships involving lengths and angles of triangles. The field emerged in the Hellenistic world during the 3rd century BC from applications of geometry to astronomical studies.

    AKA Vectors..lol In the electrical field we use Trig to determine vectors that distinguish Phase differential in multiple sine waves.

  • SocksSocks London, UK.Member Posts: 12,822

    @The_Gamesalad_Guru said:
    AKA Vectors..lol In the electrical field we use Trig to determine vectors that distinguish Phase differential in multiple sine waves.

    Yep, it's amazing how broadly appicable trig is, from the electrical field to audio synthesis, from designing bicycle wheels to making mobile apps !

  • tmanntmann Member Posts: 278
    edited July 2015

    @The_Gamesalad_Guru
    Just to be clearer then Sine and Cosine are Trigonometric Functions and are not AKA Vectors or Vector Functions :)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @tmann said:
    The_Gamesalad_Guru
    Just to be clearer then Sine and Cosine are Trigonometric Functions and are not AKA Vectors or Vector Functions :)

    Really we're going to go down this rabbit hole, okay. I said vector math which would cover any type of math needed to calculate a particular vector for the given situation. i'm really not interesting in getting into stupid semantic arguments. Here I'll put and end to this. @tmann you are the most brillant person on the planet. Does that help your shallow ego?....LMAO

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited July 2015

    Just in case anyone is a bit more curious about learning the math side of things, here are some great resources:

    PEMDAS

    Vectors

    Trig/SOHCAHTOA

    Linear Algebra/Vectors

    Most game math falls into these subjects ranges. Calculus and Statistics can also be useful and worth taking a look at once you're comfortable with the concepts of the above. Also fun to check out formulas for things such as liquid simulation, Wind simulation, etc (on wiki and such).

    Follow us: Twitter - Website

  • IceboxIcebox Member Posts: 1,485

    Thanks everyone for everything I like the tips and demo :) I will try to improve with the math

Sign In or Register to comment.