How to create custom rotation - rotates in one direction for a small time period then another
hamzeyyy
Member Posts: 25
Hi,
I want my actor to accelerate and rotate in one direction for a certain ammount of time and then rotate in another direction (oppsite to before) for another ammount of time. So it looks like the actor is 'wavey'
If you google - Sin Graph I want it to look wavey as it accelerates like that. - kind of like a custom axis.
I know how to accelerate the actor and make it rotate just not like this, I've been looking for the solution online but haven't found anything that works.
Any help?
Thanks a lot - I appreciate it
I want my actor to accelerate and rotate in one direction for a certain ammount of time and then rotate in another direction (oppsite to before) for another ammount of time. So it looks like the actor is 'wavey'
If you google - Sin Graph I want it to look wavey as it accelerates like that. - kind of like a custom axis.
I know how to accelerate the actor and make it rotate just not like this, I've been looking for the solution online but haven't found anything that works.
Any help?
Thanks a lot - I appreciate it
Comments
@hamzeyyy Hi, are you certain you want acceleration each time? Especially if the rotation one way then the other is over a short time, you're not going to see much acceleration....
Here's a gamefile test showing an actor rotating one way then the other, over and again, giving a "wavy" impression as you want (although I'll say again without any acceleration involved). Hopefully you'll live with it for what you want.
Note: the algorithm used in based on one given by @Socks - to give credit there... (A*sin(self.Time*B)+C)
To change the distance of revolution, change the first number A (shown as 10 at the moment); and to change the speed, change the number that's 1000 in the expression (B).
https://dl.dropboxusercontent.com/u/14060718/rot l&R.gameproj.zip
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Cheers for the credit gyroscope but the credit should really go to some old Greek fella from a couple of thousand - or so - years ago.
One thing though, I've never really understood the inclusion of the modulus (in this case '%360') in pretty much every use of sin/cos you see in GameSalad, perhaps I'm not understanding it correctly, but from what I can see GameSalad is never going to run out of circle ! That's the nice thing about circles, they just keep going, same deal with self-time . . . . . ?
For example the rotation in that example reads:
(10*sin((self.Time*1000)%360))
But it could simply be:
10*sin(self.Time *1000)
Unless I am being an idiot and overlooking something !?
(In which case I deny all knowledge of this post).
Hi @Socks Ha, OK! You still get credit then for bringing it to the attention of the GS community, I reckon... :-) Hey, I see what you mean... it works just fine without the modulus (so I can't see why its needed either so if you're being an idiot so am I!)
One thing though, if you change the modulus figure (360) to something else less, you get a change in behaviour, so maybe it'll be useful once in a blue moon for someone...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
You're welcome. If you mean for it to go further around, one way and another, make the number larger, so try something like 20 or 25.... experiment until it's right for you. :-)
P.S If you don't know - only change the numbers via the Expression Editor.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
. . . . 315° > 320° > 325° > 330° > 5° > 10° > 15° . . . . etc
Instead of this:
. . . . 345° > 350° > 355° > 360° > 5° > 10° > 15° . . . . etc
Which means sin (or cos) doesn't get to loop properly, so there will be a jump/glitch.
And yes, it's really useful for stuff like bounces . . . hold on I feel a demo coming up, back in a moment . . . .
Here you go, I just abused your original file (ignore the Verge Logo, it was just the first image file to hand).
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
In the below file the left circular movement has no % (or %360), the right circular movement has %180.
Am I boring you yet, that's what I fully intend to do . . . .
However your "boing" file did make my eyes go funny.... I shall be putting in an official complaint a.s.a.p. :P (It's good stuff again really, thanks!)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I am having problems with alignment though, the actor starts off in the centre and end up towards the right, I need it to finish dead on in the centre, any help?
I have tried using accelerate towards - positon 320 but it didn't help...
Hi again, @hamzeyyy I had no problems with a test using Accelerate Towards. Maybe check the X position of your actor (best it's a whole number too) and confirm it matches exactly the X position in the behaviour.
You can also use Interpolate instead if you wanted, on the actor's Y attribute, over a pre-determined time down to your base level Y position (without worrying about matching the x position).
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@hamzeyyy
The problem is that your accelerate is set to 275°.
Straight down is 270°.
Your actor is behaving correctly given the rules shown in the video - and moving 5° off axis.
Here's the film trailer based on my earlier life to give you the idea of how I learnt:
)
Seriously, with maths, apart from what I learnt from school, just checking out explanations on the internet (as long as its not too complicated...) :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
This level of trigonometry is bizarrely simple, it looks complex, it sounds complex, it can achieve (relatively) complex things, but it really is simple - once you understand what sin(angle) actually does a whole world of wobbling, swinging, circling, rotating shaking, arcing, bouncing and spiralling things is all yours !