One-way sine curve

0 favourites
  • 6 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I'm using a sine wave behaviour to move a sprite but i don't want it to 'dip' below it's starting position. Take a look (please excuse the crude drawings lol!):

    [attachment=1:1h3iad5e][/attachment:1h3iad5e]

    The straight line is the sprite's (star) starting position and this is how I have it, as you can see it dips below the sprites starting position. Imagine the straight line is the bottom of the playing area then the sprite would disappear off screen as it dips below and I don't want this.

    I would like to have it move like this:

    [attachment=0:1h3iad5e][/attachment:1h3iad5e]

    I know I can do this if i start the sprite further up the curve but that's not what I want. Is it possible using the Sine wave behaviour? My maths is non existent so I really don't want to uses mathematical expressions if at all possible.

    Any help would be really appreciated.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I know I can do this if i start the sprite further up the curve but that's not what I want.

    Why not? It is the solution to your problem. The lowest point of a sine wave starts at 75% of the period's length. So, if the period is 2 seconds, the period offset would need to be 1.5 seconds.

  • [quote:1cbizbwu]Why not? It is the solution to your problem.

    Because that's not what I want, I'd like the sprite to start at one side of the screen, sine wave to the other side and back again to the start position. I've played around with the Period (which is 5) and Period Offset but it's still moving off the screen.

    You can see what I mean here: http://www.madladdesigns.co.uk/extras/invaderoids

  • as tulamide said it is just down to the offset (sine wave) and moving its start point up/across as needed - see attachment.

  • Ahh.. there's 'mathery' involved! - spSineWave.Y-spSineWave.Sine.Magnitude and I wouldn't have a clue about this. I was trying to do it straight through the behaviour. Thanks for your help guys and I'll take a good look at the example RamPackWobble and see what I can do.

  • this translates to

    (the y position I wish to start at) -(the distance (magnitude) of the sine wave)

    even I can follow that maths...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)