"Simple" back and forth sin movement

CircleTimeCircleTime Member Posts: 84
edited November -1 in Working with GS (Mac)
I've been studying this:
http://gamesalad.com/wiki/how_tos:gsc_wave_movement
I'm trying to have a simple back and forth with the gentleness of sin math.
The example is proving too complex for me to reassemble into just a simple back and forth on X access. Embarrassed, but head spinning.
Can anyone help simplify this for me?
Thank you,
CircleTime

Comments

  • CircleTimeCircleTime Member Posts: 84
    Sorry for bumping.
    I'm studying the examples from:
    http://gamesalad.com/wiki/how_tos:gsc_wave_movement
    Copied exactly, the first example has the left and right movement that I want, however, the actor also is rising up on the Y access. I'm trying to unlink the rising up on Y, but the equation seems to be so tightly tied to this exact result. All my tinkering seems to just break the system.
    Thoughts?
    Thank you,
    CircleTime
  • micksolomicksolo Member Posts: 264
    what kind of movement are you after? if its just simple back and forth with gentle rising and falling you can probably do it with interpolate behavior and a few timers to control the movement state

    eg. every 1 second change attribute MoveState 1 to (MoveState1+1)%2

    then

    When movestate = 1 interpolate actor to pos x whatever
    and add change velocity + gravity to make it fall again.
  • CircleTimeCircleTime Member Posts: 84
    Thanks micksolo,
    The specific movements I need are simply "left and right" with no rise or fall on Y whatsoever.
    Additionally I would like simple "up and down" with no drifting on the X whatsoever.
    I'm hoping for that wonderful sin math movement, rather then abrupt starts and stops.
    I've been experimenting and searching the forums for a solution, and it usually leads to a reference to this tutorial:
    http://gamesalad.com/wiki/how_tos:gsc_wave_movement
    However, this tutorial creates something more complicated than I want, such as "left and right" + rising up. When I try and tinker with the code for my simpler goals, I just break it.
    Any help with this is greatly appreciated.
    Thanks again,
    CircleTime
  • dre38wdre38w Member Posts: 79
    I'm wanting something similar. Except I'm looking for the actor to do an arch one time and stop at a position.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @CircleTime: Here is the basic formula for what you want:

    halfWaveHeight * sin( timeFactor * oscillationSpeed) + centerOfWave

    To apply that in GameSalad, use something like this:

    Constrain Attribute
    .....self.Position.X To: 230 * sin( self.Time * 200) + 240

    Hope this helps!
    Joe
  • CircleTimeCircleTime Member Posts: 84
    @firemaplegames - Thank you very much! Works perfect. This is exactly what I was looking for.
  • dre38wdre38w Member Posts: 79
    Oh. Sorry. I totally misunderstood what you were trying to do. What I'm trying to do is nothing like what you wanted. haha Sorry for an irrelevant post.
Sign In or Register to comment.