playMaker

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

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
How to make wave/sine movement?
« on: October 30, 2018, 09: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

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make wave/sine movement?
« Reply #1 on: October 31, 2018, 05: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: 480
Re: How to make wave/sine movement?
« Reply #2 on: October 31, 2018, 05: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

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

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to make wave/sine movement?
« Reply #4 on: November 01, 2018, 10: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
3. Add "Float Add" every frame (addition to movement speed + vertical movement)
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, 12:19:09 PM by krmko »
Available for Playmaker work

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: How to make wave/sine movement?
« Reply #5 on: November 01, 2018, 10: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.

1.jeanfabre, i would love to learn the curve. can u point some unity tutorial about this.Thanks

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, 10: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.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to make wave/sine movement?
« Reply #7 on: November 06, 2018, 12:30:46 PM »
Energy bar toolkit for sine waves? I guessed you missed the thread, but yeah, it's an awesome asset, i'm using itnl too.
Available for Playmaker work

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make wave/sine movement?
« Reply #8 on: November 07, 2018, 03: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, 05: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...