YesNoOk
avatar

Questions about trigonometric and logarithmic triggers (Read 656 times)

Started by Fighting Toys Freak, August 18, 2014, 02:51:47 AM
Share this topic:
Questions about trigonometric and logarithmic triggers
New #1  August 18, 2014, 02:51:47 AM
  • **
  • New changes, new me!
After reading so many enlightening threads about how I could improve on my general manner of coding, I've noticed that Mugen has an advanced side for coding. This side of coding particularly pertains to use of trignometric and logithrimic triggers. In the effort to grasp the understanding of the usefulness of those triggers, I would like to know about the usefulness of trignometric and logithrimic triggers, such as Exp, arcsin, sin, e, log, Ln etc. Furthermore, I would like to know of how I could utilize them properly for certain coding situations. Providing an example of their usages would be helpful. All suggestions will be considered.
Last Edit: August 18, 2014, 10:45:30 PM by Fighting Toys Freak
Re: Some questions in my mind
#2  August 18, 2014, 04:52:51 AM
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
The trigonometric functions have more utility than the logarithmic ones. I've used both, however. Really, that's up to you and how you want to use them. If you can visualize the curves they create and map "time" to those curves, then you will be able to see what you can do with them. Think of "sin" and its curve. At it's most basic form, you have a simple "up and down" motion. Now, on the graph, this shows a valley of changes between 1 and -1 at a constant rate. Knowing this, you can map that to time and use it as a value for velocity, causing your character to appear as they were "floating."

Really, I think you should look up the mathematical importance of these things and then try applying them to mugen. You have to know one before the other.

-[Все слова это только слова.]-
Re: Some questions in my mind
#3  August 18, 2014, 06:13:31 AM
  • **
  • GEE GEE
all of these movements are really used to describe the movement of a particle within mugen space. They are just shortcuts so you don't have to define a velocity for each tic. Luckily, mugen is only 2D, so that simplifies our usages of these triggers by a ton. I've used trigonometry in a lot of my coding to dynamically change the angles of projectiles. lets say you want to make a projectile target P2 (wherever he is... instead a simple forward moving projectile).

the code for a projectile moving forward (and no other direction) would be:
X = 5
Y = 0

in the velset state controller. but if you want to move it angled, you would have to breakdown the vector 5 into it's X and Y components using sin and cos


the angled code above sets an initial angle, and the sin and cos are used to break down the hypotenuse (vector movement speed of 5) into it's X and Y velocities.

To take this even further, you can create a variable to set the angle to whatever you want. To make your projectile target P2 (or if you even wanted, another helper). you would have to find the angle between P1 and P2 using tangent:


**Note the code in the picture should say "atan, not arctan". and value should be var(1)

set this angle to var(1). and you will have created a projectile that can track P2. I usually code this way, so that I don't have to upload the same sprites at different angles.

The more interesting and advanced side of coding are the use of data structures to create advanced effects or systems. ie. if you've ever programmed a stack or queue, you can create an effect similar to reversing time. the possibilities are endless with your own imagination being a limitation, hence the name "mugen", the Japanese word for infinity.

wat.
Re: Some questions in my mind
#4  August 18, 2014, 06:29:21 AM
  • ******
  • 90's Kawaii
  • :thinking:
    • Guatemala