# How do I start a sine or cos wave at a custom point in time?

right now, if an actor is triggered to be constrained to a sine wave's rotation, it will glitch and teleport to that rotation before smoothly being rotated along the sine wave smoothly. I want it to start at 0 rotation and slowly and smoothly start rotating

• @ETGgames said:
right now, if an actor is triggered to be constrained to a sine wave's rotation . . .

Do you mean the angle on which a sine function is operating ? (a sine wave doesn't have a rotation) ??

@ETGgames said:
it will glitch and teleport to that rotation before smoothly being rotated along the sine wave smoothly. I want it to start at 0 rotation and slowly and smoothly start rotating

I'm not 100% what you are saying here, but this is how it works . . .

sin(angle) will give you the sine of whatever angle is in the brackets.

• yes i mean the angle of the sine wave. if not, then can you tell me how to have counter clockwise interpolation of rotation

• edited November 2015

@ETGgames said:
yes i mean the angle of the sine wave.

So what is the question then ? It's not clear what you are asking ?

@ETGgames said:
if not . . .

If not what ?

@ETGgames said:
then can you tell me how to have counter clockwise interpolation of rotation

Interpolation ? I thought you were using constrain ?

You can interpolate in a counterclockwise direction by simply interpolating to a positive value larger than the current rotation.

So if your actor's rotation is 0° then interpolating the rotation to (for example) 500° will make it rotate counterclockwise.

• edited November 2015

@Socks, I think the question is related to forcing the result of a sin() function to initially be zero. For example, if game.Time is 12.999 when the scene begins and self.Rotation is constrained to a sin() function, how can the starting value of that function be zero?

I imagine the answer is to use a custom time (game.myTimer) starting at 0 -- possibly along with an offset value depending on the sin() function -- and counting up. But you may have a better suggestion.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• If you want it to be 0 when you start the scene, just use self.Time.

If you want to start at, say, where it would be when time = 12, just do self.Time+12.

If you want to start it at 0 but at a time triggered at some point after the scene start, just make a real self attribute and change it to self.Time when you want the sin() to start, and then subtract it from self.Time (or game.Time if you use that) in your equation.

• edited November 2015

@tatiang said:
@Socks, I think the question is related to forcing the result of a sin() function to initially be zero. For example, if game.Time is 12.999 when the scene begins and self.Rotation is constrained to a sin() function, how can the starting value of that function be zero?

Ah! I see, yes that makes sense.

@tatiang said:
I imagine the answer is to use a custom time (game.myTimer) starting at 0 -- possibly along with an offset value depending on the sin() function -- and counting up. But you may have a better suggestion.

I'm still not 100% sure what's need, but assuming this is for an actor that is travelling in an orbit in a CCW direction - and needs to always start at 0° (or any specific angle) - then there are couple of very straightforward methods that avoid self.time and game.time's habit of starting before you get to the party.

Method 1:

main actor
--Constrain X to radius * cos (self.rotation) + origin
--Constrain Y to radius * sin (self.rotation) + origin
--Rotate behaviour (CCW)

With this method you can trigger the Rotate behaviour however you like - and whenever you like - and if you want a specific start angle simply point the actor to the angle you want the orbit to start at.

. . . . . . . .

Method 2: (basically the same method but with more control)

main actor
--Constrain X to radius * cos (controller.rotation) + origin
--Constrain Y to radius * sin (controller.rotation) + origin
--Constrain R to controller.rotation

controller actor
--Rotate behaviour (CCW)

With this method you can also trigger the Rotate behaviour (of the controller) however you like - and whenever you like - and if you want a specific start angle simply point the controller to the angle you want the orbit to start at . . you can also ramp up the speed of the orbit by interpolating the angluar rotation of the controller, introduce angular drag, go into reverse and many other things that would be fiendishly difficult if you were using game.time/self.time for the angle.

• edited November 2015
• Method 2: (More control)