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

0 favourites
  • 7 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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
  • Thank you that should work.

  • 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

  • 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.

  • 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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)