# Playmaker Forum

## Playmaker Help & Tips => Playmaker Help => Topic started by: hoyoyo80 on October 30, 2018, 06:29:54 PM

Title: How to make wave/sine movement?
Post by: hoyoyo80 on October 30, 2018, 06:29:54 PM
Hi all,

Anybody know how to make sine/wave movement as seen in most shootemup?

I try to use animation but i realize it use exact position.
Any easy way other that math?

Thanks
Title: Re: How to make wave/sine movement?
Post by: jeanfabre on October 31, 2018, 02:45:24 AM
Hi,

you can use Curves as well, but math is likely going to be the only way for proper control.

Bye,

Jean
Title: Re: How to make wave/sine movement?
Post by: Thore on October 31, 2018, 02:58:21 PM
Maybe a sideways “move towards” action between two waypoints (all three things child under one patent), with the easing function (I believe sine is there too). And a different, separate FSM, that moves the parent object forward. That way, the thing would describe a sine movement, or close enough.
Title: Re: How to make wave/sine movement?
Post by: jeanfabre on November 01, 2018, 02:03:29 AM
Hi,

Have you checked this: https://assetstore.unity.com/packages/templates/systems/shmup-starter-kit-for-playmaker-11070

Bye,

Jean
Title: Re: How to make wave/sine movement?
Post by: krmko on November 01, 2018, 07:34:30 AM
For horizontal movement:

FSM 1

1. Translate horizontally with desired speed

FSM 2

1. Create float variable vertical movement speed and set it to zero
2. Create float variable addition to movement speed
4. Add "Float Compare" and compare vertical movement speed with desired vertical movement speed limit
5. When it hit the threshold, "Float Subtract" every frame (vertical movement - addition to movement speed)
6. Float compare again, when it reaches a defined negative threshold, repeat.

Using this way you can get a smooth sine movement, but there are certain cons to this approach, first being the dependence on frame rate because of float imprecision, the second one being making this a bit of a drag to modify amd get the values just right for desired result.

Tweening only vertically while translating horizontally does not work , so it's either this way, tweening the whole path, or code.

Edit: typos
Title: Re: How to make wave/sine movement?
Post by: hoyoyo80 on November 01, 2018, 07:41:38 PM
Hi all, first of all thanks:)

I figure that math is the best way just wanting to explore easier method:) Since in some shootemup ive seen, the enemies move in circle pattern that move out of the screen.I thot maybe unity/playmaker have a waypoint etc.Ive read about DoTween but im not sure whether itll help.

2.Thore, yes, thinking of that waypoint too.Thanks

3.krmko, Thanks. That could be useful.

Title: Re: How to make wave/sine movement?
Post by: Doh on November 06, 2018, 08:06:18 AM
I picked up this https://www.assetstore.unity3d.com/en/?stay#!/content/7515 ages ago, it comes with Playmaker actions. I don't use it at the moment as I like to avoid relying on too many assets, however it worked well when I tested it.
Title: Re: How to make wave/sine movement?
Post by: krmko on November 06, 2018, 10:30:46 AM
Energy bar toolkit for sine waves? I guessed you missed the thread, but yeah, it's an awesome asset, i'm using itnl too.
Title: Re: How to make wave/sine movement?
Post by: jeanfabre on November 07, 2018, 01:06:55 AM
Hi,

You can use the action Sample curve to get a float value, which could be the delay for each instance based on a position ratio from the vessel.

Bye,

Jean
Title: Re: How to make wave/sine movement?
Post by: Doh on November 15, 2018, 03:00:15 AM
Energy bar toolkit for sine waves? I guessed you missed the thread, but yeah, it's an awesome asset, i'm using itnl too.

Massive oops, sorry must have returned to the wrong tab after fetching the link...