Author Topic: Trigger following a Timeline  (Read 1369 times)

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 48.0.2564.97 Chrome 48.0.2564.97
    • View Profile
  • Playstyle: Keyboard
Trigger following a Timeline
« on: February 05, 2016, 05:19:34 PM »
Hello,
I am trying to make it so when the player hits the trigger object it makes an object further down shoot up and then fall down. I can make it shoot up and fall down (similar to tossing a ball in the air) easily with a Timeline, but I don't want the timeline to start until the player reaches the trigger objects. I've approached it from several different ways, but it mostly ends with the trigger doing nothing and the object just sits there or the object triggers right away. I'm using yoyo's studio engine. 
Some help would be appreciated. Thanks.

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.103 Chrome 48.0.2564.103
    • View Profile
  • Playstyle: Keyboard
Re: Trigger following a Timeline
« Reply #1 on: February 05, 2016, 08:27:39 PM »
Does it only need to activate once? And do you plan on having multiples of these in the same room that you want to trigger independently?

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 48.0.2564.97 Chrome 48.0.2564.97
    • View Profile
  • Playstyle: Keyboard
Re: Trigger following a Timeline
« Reply #2 on: February 05, 2016, 10:32:47 PM »
Yeah unless you die then it would reset. Also I would like to have more than one in a room that would be activated separately and follow different timelines.

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.103 Chrome 48.0.2564.103
    • View Profile
  • Playstyle: Keyboard
Re: Trigger following a Timeline
« Reply #3 on: February 06, 2016, 06:18:27 AM »
So this is the solution I use for things like this. I'm sure there's a more elegant way, but I haven't found it yet.

You're going to need two paired objects. I'm going to call them objLinkTrigger1 and objLinkRecieve1 for the sake of writing this, but you can go with whatever suits your style obviously. Same with the variables in the following code as long as you make sure to change every instance of them.

objLinkTrigger1 should have this code:
Create Event:
triggervar = false;

Collision with Player Event:
triggervar = true;

Then, in objLinkRecieve1 put this:
Create Event:
timelinevar = false;

Step Event:
if timelinevar = false {
    if objLinkTrigger1.triggervar = true {
        timeline_index = TimelineName
        timeline_running = true;
        timelinevar = true;
    }
}

Using this method you're going to have to make multiple linked pairs (I would call them, say objLinkTrigger2 and objLinkRecieve2) for them to be in the same room. On the plus side, that makes it easier to make each one behave in a specific way, or you could have two objects linked to the same trigger, etc. If you want to make it reset after the timeline has ended, just put a step at the end of the timeline that changes the variables in each back to their default state.
« Last Edit: February 06, 2016, 07:54:03 AM by Kyir »

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 48.0.2564.97 Chrome 48.0.2564.97
    • View Profile
  • Playstyle: Keyboard
Re: Trigger following a Timeline
« Reply #4 on: February 07, 2016, 11:53:25 AM »
Works perfect! Thanks :)