How do I make an actor move in a horizontal sine wave?

ETGgamesETGgames Member, PRO Posts: 190

I currently only know how to use the vertical sine wave function where i constrain an actor's y position to, for example, 10sin(self.Time300)+160. This is to move the actor up and down smoothly. However, I cannot figure out how to make the actor move rom left to right in an arcsine wave. I tried constraining its x position to 10asin(self.Time300)+284, but that does nothing I want it to do.

Best Answers

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

    @EthaneusTheGreat said:
    Can you please explain in further detail how to do this is how to use arcsine?

    Not 100% what this question means ?

    @EthaneusTheGreat said:
    All I want is the EXACT same movement of a sine wave going up and down, but instead from right to left.

    Use the equation you have in your first post, but instead of constraining the actor's Y position to that equation, constrain the actor's X position to that equation.

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

Answers

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

    If you want the actor to move left to right use the Move / Move To / Interpolate or even Accelerate behaviour (although with the Accelerate behaviour the initial pitch of your sine wave will be squashed up before it hits max velocity).

  • ETGgamesETGgames Member, PRO Posts: 190

    Not what I want, because the move behaviour is not a smooth movement, it remains at a constant speed. The sine wave slows down as it reaches the top and bottom. They are different things.

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

    @EthaneusTheGreat said:
    Not what I want, because the move behaviour is not a smooth movement, it remains at a constant speed. The sine wave slows down as it reaches the top and bottom. They are different things.

    The move behaviour is a smooth movement, that is to say its velocity is constant.

    A sin value slows (in its vertical speed) as it reaches 90° and 270° (the 'top' and 'bottom' of its extent), but a sine wave's horizontal movement is perfectly constant, it doesn't slow down or speed up.

    Trust me ! :) Try it !

    Constrain the actor's Y position to the sin (or cos) of an ever increasing angle - and use Move / Move To / Interpolate or even Accelerate behaviour to move the actor left to right and you will get a sine wave.

  • ETGgamesETGgames Member, PRO Posts: 190

    Can you please explain in further detail how to do this is how to use arcsine? All I want is the EXACT same movement of a sine wave going up and down, but instead from right to left

  • ETGgamesETGgames Member, PRO Posts: 190

    I'm pretty sure that doesn't work? Have u tried r is it just a theory?

  • AdrenalineAdrenaline Member Posts: 523

    There's no reason it shouldn't work. If it works in one direction, it will work in another. All you're doing is constraining a different attribute to the same value that you've already said works just fine.

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

    @EthaneusTheGreat said:
    I'm pretty sure that doesn't work?

    Ok, not a lot I can say to that, I can't force you to try it :smiley: lol, especially if you are sure it doesn't work.

  • ETGgamesETGgames Member, PRO Posts: 190

    I've tried it and it didn't work. Aren't sine waves for up and down movement only tho?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    edited April 2014

    @EthaneusTheGreat what is your ultimate goal? Just to move up and down in a straight line at a constant speed?

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

    @EthaneusTheGreat said:
    I've tried it and it didn't work.

    You must have made a mistake when setting up your rules / behaviours.

    'It didn't work' doesn't give any clues as to what the problem might be, it's usually best to describe what did happen (i.e. it went the wrong way, it moved but then stopped, it didn't move at all . . . . etc etc)

    Could you post a screenshot of the rule that moves your actor so we can try and see if you've made a mistake anywhere.

    @EthaneusTheGreat said:
    Aren't sine waves for up and down movement only tho?

    No, not at all, sine waves aren't for anything specific, they are a maths function, you can do what you like with them, you can use them to make an actor cycle through the colours of the rainbow or travel in a wiggling, random path, or bounce, or make an actor grow and shrink in size as you tilt your iPad left to right . . . and a million other things.

  • SocksSocks London, UK.Member Posts: 12,822

    @jonmulcahy said:
    EthaneusTheGreat what is your ultimate goal? Just to move up and down in a straight line at a constant speed?

    I think (but not 100% sure) he wants an actor to move left to right.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    why not do something like

    if position Y = 100
    interpolate y to 200 over 1 second at a linear speed (or ease in.out to slow down)

    if position y = 200
    interpolate y to 100 over 1 second

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

    @jonmulcahy said:
    why not do something like

    if position Y = 100
    interpolate y to 200 over 1 second at a linear speed (or ease in.out to slow down)

    if position y = 200
    interpolate y to 100 over 1 second

    He wants to move left to right (rather than in the Y direction), he's already got the constrain working fine for Y, he just needs the lefthand side of his behaviour to read position.x rather than position.y.

    Oh . . . . damn it ! I'll just make a demo to see if that is what he actually wants . . . . :smiley:

  • ETGgamesETGgames Member, PRO Posts: 190

    Socks, I love you :D . I was accidentally using the change attribute instead of contrain (yes.. I know!)

  • SocksSocks London, UK.Member Posts: 12,822

    @EthaneusTheGreat said:
    Socks, I love you :D

    I hope it's a manly love, you know, like 'bros', no touching or anything weird.

    @EthaneusTheGreat said:
    I was accidentally using the change attribute instead of contrain (yes.. I know!)

    I've put your name down on 'the list' for that, I can't tell you anything about the list, just that you don't want to be on it. :smiley: :wink:

Sign In or Register to comment.