# playMaker

### Author Topic: How to make wave/sine movement?  (Read 1224 times)

#### hoyoyo80

• Junior Playmaker
• Posts: 96
##### How to make wave/sine movement?
« 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

#### jeanfabre

• Hero Member
• Posts: 15069
• Official Playmaker Support
##### Re: How to make wave/sine movement?
« Reply #1 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

#### Thore

• Sr. Member
• Posts: 374
##### Re: How to make wave/sine movement?
« Reply #2 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.

#### jeanfabre

• Hero Member
• Posts: 15069
• Official Playmaker Support
##### Re: How to make wave/sine movement?
« Reply #3 on: November 01, 2018, 02:03:29 AM »

#### krmko

• Beta Group
• Hero Member
• Posts: 1050
##### Re: How to make wave/sine movement?
« Reply #4 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
« Last Edit: November 01, 2018, 09:19:09 AM by krmko »

#### hoyoyo80

• Junior Playmaker
• Posts: 96
##### Re: How to make wave/sine movement?
« Reply #5 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.

#### Doh

• Full Member
• Posts: 124
##### Re: How to make wave/sine movement?
« Reply #6 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.

#### krmko

• Beta Group
• Hero Member
• Posts: 1050
##### Re: How to make wave/sine movement?
« Reply #7 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.

#### jeanfabre

• Hero Member
• Posts: 15069
• Official Playmaker Support
##### Re: How to make wave/sine movement?
« Reply #8 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

#### Doh

• Full Member
• Posts: 124
##### Re: How to make wave/sine movement?
« Reply #9 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...