Wiggle function

KatAppsKatApps Member, PRO Posts: 84
Hey all,

I'm trying to create a wiggle function for one of my games, which means a character will rotate slowly to the left and after .5 seconds rotate back the other way slowly to the right, and repeat, over and over. I'd like the character to be automatically wiggling upon entering a scene, and then after being touched will start to do something else (like fly away or some other action).

It seems like something simple, but I can't quite figure out how to get the wiggle thing to work. Can anyone help?

Thanks!
kat

Comments

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

    @KatApps Hi Kat, here's one way of getting the effect you're after; hopefully this'll help you out....

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013

    @KatApps Hi Kat, here's one way of getting the effect you're after; hopefully this'll help you out....
    Never forget that the answer is always AAA*sin(self.Time*BBB)+CCC ;)

    (except in this case we don't even need the CCC part)

    Constrain rotation to: AAA*sin( game.Time *BBB)

    AAA = range of rotation
    BBB = speed of rotation

    http://www.mediafire.com/?4hvjez20tz1lan2
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @KatApps Hi Kat, here's one way of getting the effect you're after; hopefully this'll help you out....
    Never forget that the answer is always AAA*sin(self.Time*BBB)+CCC ;)

    (except in this case we don't even need the CCC part)
    It's finally sunk in the power of this relatively straightforward equation, @Socks, cheers! (Now I fully understand how it does what it does). :-)

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

  • KatAppsKatApps Member, PRO Posts: 84
    Thanks for the responses! @gyroscope - I saw the wiggle function work great in your file.. tried dragging that actor into my scene but it doesn't seem to work there :(
  • ElfizmElfizm Member Posts: 489
    edited March 2013
    You have to set up the way it is set up, which could mean creating attributes with same names ect
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2013

    Hi @KatApps

    As @Elfizm says: you'd have to duplicate the rules from the file I supplied, in you actor in your file.

    Another way is to select all the rules in the yellow actor in the file supplied and then option drag across to the rules of your actor in your file, to copy the rules in one go. (Don't forget you'll still have to remake all the attributes used though....)

    Hope you sort it/have sorted it. :-)

    PS One finally thing to mention: the rules from When scene.Wiggle is false to the end, can all be replaced with the Constrain Attribute @Socks suggested, if you like; it does exactly the same thing, but obviously with less programming.

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Thanks for the responses! @gyroscope - I saw the wiggle function work great in your file.. tried dragging that actor into my scene but it doesn't seem to work there :(

    Did you try out my very simple wiggle above ?

    With that you can either drag the actor from my project into yours, or just do as @gyroscope says and drag the rules over - it will copy trouble free as the wiggle is done without rules/attributes (etc).
  • KatAppsKatApps Member, PRO Posts: 84
    edited March 2013
    Wow, thanks to all of you for your help!

    @gyroscope .. I still have a lot to learn here so I guess recreating all those attributes is still a bit confusing :P

    @socks .. I did end up using that file you sent and it seems to be moving me in the right direction. I now have a character that wiggles upon entering the scene!

    The second part of this dilemma is now to get the actor to stop wiggling/moving after I've tapped it. The linked file shows this.. the actor wiggles, I tap it and it gets bigger and increases the score on the top right (which is what I want it to do).. and then I'd like it to freeze after this.. anyone know a way to accomplish this?

    http://www.mediafire.com/?db47tma7flti3i1

    This community is great. I really appreciate all the posts and look forward to getting better so I can contribute more :)

    Kat
  • SocksSocks London, UK.Member Posts: 12,822
    @KatApps

    To keep it simple you could simply kill the old sun and replace it with a static version.

    Like this: http://www.mediafire.com/?zswa8gj8hy5bc8d
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You could always just constantly interpolate the rotation back and forth if you wanna eliminate the constrain.
  • KatAppsKatApps Member, PRO Posts: 84
    edited March 2013
    Thanks for the suggestion @tenrdrmer !

    @socks .. I tried the static version idea and it seems to work great!

    I'm stoked to finally move forward on my app, thanks so much for following up on this, I greatly appreciate it :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2013

    Good it's all moving forward for you, Kat. :-)

    Here's yet another way to have your sun actor stop rotating when you click it:

    Make a self boolean attribute, let's call it GoStop.

    Put the Constrain Behaviour in a Rule: When self.GoStop is false

    And finally put a Change Attribute GoStop to true in the touch rule, maybe just after the last interpolate behaviour there.

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

  • KatAppsKatApps Member, PRO Posts: 84
    Thanks @gyroscope .. I'll try that one too!
Sign In or Register to comment.