Wave movement up and down

I'm trying to create a wave movement (up and down) for my actor and at the same time its moving across the screen to the right. Any suggestions? :)

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2014

    Move the actor across the screen to the right however you like, you can use Move, Move To, Interpolate, Accelerate . . . etc.

    Then constrain the actor's Y position to: AAA * sin(self.time * BBB)+CCC

    AAA = height of the wave.

    BBB = pitch of the wave.

    CCC = vertical centre point of the wave.

    So for example, in a landscape iPad sized project try 200 * sin(self.time * 100)+384

  • Boorje75Boorje75 Member Posts: 13

    The actor I want a wave motion on spawns randomly between 500 and 900, do I have to take that i consideration when setting my values?

  • TosanuTosanu Member, PRO Posts: 388

    You need to create an attribute on the actor to track its Y position. make a YActor attribute, and have it Changed to Self.positionY as one of the first behaviors. Then replace the CCC in the other formula with YActor or whatever you call it. That way, you can drop an actor anywhere and it will center its wave motion on that spot.

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2014

    Hi @Boorje75‌

    i'm sure @Socks won't mind me answering: you mean between 500 and 900 being the height of the wave?

    If so, try this: make an integer attribute, let's call it WaveHeight. I'll assume you'll trigger a new spawn every time with a boolean (Let's Call that SpawnGo)

    Rule: When SpawnGo is true
    Change Attribute SpawnGo to false
    Change Attribute WaveHeight to random(500,900)
    Constrain Attribute WaveHeight * sin(self.time * 100)+384 -- other figures as example numbers from @Socks--
    

    Edit: typing while @Tosanu was typing...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Boorje75Boorje75 Member Posts: 13

    Thanks for the help! I figured it out :wink:

Sign In or Register to comment.