YesNoOk
avatar

Sine movement - stages & chars (Read 7240 times)

Started by O Ilusionista, April 23, 2011, 04:51:06 AM
Share this topic:
Sine movement - stages & chars
#1  April 23, 2011, 04:51:06 AM
  • ******
  • Part of the OpenBOR dev team
  • 22 years of Mugen and counting...
    • Brazil
    • www.brazilmugenteam.com
I will talk about how to make Sine movement on chars and stages, to make more smooth animations.
I will explain more about Sine below.

STAGES:
take a look at  http://www.elecbyte.com/mugendocs/bgs.html for more info about stages

[BG mirror]
type = normal
spriteno = 6,0
start = 0, -142
delta = 0.7,0.9
layerno = 0
mask = 1
sin.y = -8, 240


Let me explain the trigger:

sin.y = -8, 240

- Sin is senoide curve

http://en.wikipedia.org/wiki/Sine_wave

- sin.y means that we are going to have the effect just on the y axis (vertical). For horizontal movement, use sin.x   (*)

- -8 is how much the element will move (keep in mind that we are talking about a Senoide, so it will move the amount*2 = 16 (-8 and 8).

- 240 is the total time of a whole curve (the up and the down anim).

Some images to illustrate the effect:


(*) on Mugen 1.0 this parameter is basically superseded by the SinX background controller.
Look at http://www.elecbyte.com/mugendocs/bgs.html#background-controllers

CHARS:

On chars, its a bit more complex.

From SodonHID's codes:
Quote
[State xxx, x]
type = VelSet
trigger1 = 1
X = 3*sin(time/4.0) ; ** Originally, it was (time/4)
Y = 3*cos(time/4.0); ** Originally, it was (time/4)

4 is the frequency (the "speed"). 3 is the range (or amplitude, diameter)

** Using Bia words:
It may seem ridiculous, but time/4 will never bring a fractional result (5 / 4 = 1 for mugen). While time/4.0 results in a fractional number.

To summarize:
value / integer = integer division (without fraction). The result is an integer
value / actual value (eg 1.0) = split real (fraction). The result is a real number.


By ChonWang:
Just to help:

x = sin (time * A) * B
y = cos (time * A) * B

. The lower | A | and | B |, spins more slowly
. The lower | A | or higher | B |, the larger the radius


Notes:
- Signal (A × B) indicates the direction: counterclockwise (+), clockwise (-)
- The addition of VelAdd creates a helix
- | x | x is the module, ie the absolute value of x.

hope that is helps.
Re: Sine movement - stages & chars
#2  April 23, 2011, 07:49:51 AM
  • ****
    • Japan
Very interesting.

Also worth mentioning is that moves such as Kyosuke's Cross Cutter or Ingrid's projectiles are only possible using sine movement, so that's definitely one application that can be observed as an example.

Learning how to use sine curves in the movement of objects is something that will make trajectories look beautiful, natural and professional if combined with proper angledraw coding as well. :) (See Babel Sword, by Tatsu)
Personal discord: Vans#9119
Re: Sine movement - stages & chars
#3  April 23, 2011, 10:09:40 AM
  • ******
  • Part of the OpenBOR dev team
  • 22 years of Mugen and counting...
    • Brazil
    • www.brazilmugenteam.com

2OS

Re: Sine movement - stages & chars
#4  April 23, 2011, 11:26:33 AM
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
Learning how to use sine curves in the movement of objects is something that will make trajectories look beautiful, natural and professional if combined with proper angledraw coding as well. :) (See Babel Sword, by Tatsu)

Strider Hiryu's Ouroboro's is another example of ^ that.



I spam the hell out of these functions lolol. I used both of them to make ""Gecko's DNA Twirl Laser"" from Einhänder as a move, and for an orb aura.

Speaking of orb aura's, I think anyone looking to code Rose's ""Soul Satellite"" will find this useful.
Re: Sine movement - stages & chars
New #5  August 10, 2021, 04:46:07 PM
  • ****
  • WIP: SF4 CE
A small advice for those of us who are not so savvy in math, something Whiplash told me.

Say you had a *character* object that goes IN SYNC with a *stage* object.

Your stage object goes like this:
sin.y = -10, 220

Then you'll need to use this in your PosSet for the Character/Helper:
y = - 10 * Sin((2*(pi)/220.0) * time)

Last Edit: August 10, 2021, 07:09:18 PM by Lasombra Demon