# How do I predetermine the period offset of my sine movement?

Get help using Construct 2

### » Sun Mar 06, 2016 5:51 pm

So i'm working on a project with spikes that move up and down at variable speeds, from the ceiling of a room to the floor of that room. The distance in between the ceiling and the floor is also variable. I need to know how I can set the offset of the period on the sine movement of the spike based on those variables so that no matter what the height of the room or the speed of the spikes is, the spike always starts at it's highest point. As of now I can set the magnitude of the sine to be equal to the height of the room, but that only makes it go halfway down and then travel too far back upwards.
B
5
Posts: 10
Reputation: 247

### » Sun Mar 06, 2016 6:31 pm

What you can do is place your spikes half-way between the ceiling and the floor, then set the sine's magnitude to half the distance between the ceiling and the floor.

If that distance varies, you'll have to compute it somehow at the start of the layout or when the spike is created.

In the sine behavior, set the movement to vertical and your period offset to :
- 0 if you want the spikes to start at the middle.
- quarter of your period if you want them to start at the floor
- minus quarter of your period if you want them to start at the ceiling
B
44
S
14
G
10
Posts: 166
Reputation: 7,779

### » Sun Mar 06, 2016 6:51 pm

Thank you that should work.
B
5
Posts: 10
Reputation: 247

### » Sun Mar 06, 2016 10:23 pm

You're welcome, there's so much cool features that can be implemented using the sine behavior, I'm also experimenting with it. Good luck for your project
B
44
S
14
G
10
Posts: 166
Reputation: 7,779

### » Thu Mar 10, 2016 1:27 am

is it possible to make the period offset variable? since the period is variable I need a way to automatically set the period offset to minus one quarter of the period.
B
5
Posts: 10
Reputation: 247

### » Thu Mar 10, 2016 1:38 am

Period offset
The initial time in seconds through the cycle. For example, if the period is 2 seconds and the period offset is 1 second, the sine behavior starts half way through a cycle.

Period offset random
A random number of seconds added to the period offset for each instance. This can help vary the appearance when a lot of instances are using the Sine behavior.

https://www.scirra.com/manual/103/sine
B
25
S
14
G
139
Posts: 876
Reputation: 72,510

### » Thu Mar 10, 2016 1:38 am

Never mind, I found that if I set the guillotine to be right in the center of the y axis, I can set the sine cycle position to 0.75, which makes it start at the top.
B
5
Posts: 10
Reputation: 247