Move an object to the [current] position of another object

Sep 20, 2016

I have an object[A] with four motion paths (up/down/left/right) that can be moved around the screen at the user's will.

I have another object[B], which I would like to have move to the then-current position of object[A] using a trigger.

Any clues?

11 Replies
Simon Wood
Joanne Chen

Hi Simon, do you use triggers (click buttons/press keyboard) to move your object[A]? If yes, do you want your object[B] to move like it is chasing object[A]?

Hi Joanne,

Yes, and yes - but it's more complex than that.  I've figured out that I can group both objects them on a single motion path.  That doesn't work in this situation because:

Object[A] is a spaceship.  Object[B] is a bullet, that the spaceship fires, when user presses space bar.  I want Object[B] to move with Object[A], until the space bar is pressed, at which point I want it to move up on a straight line.  At this time I would need both objects to "ungroup".

Simon Wood
Joanne Chen

Simon, does the bullet is used for one time fired, or you want it fires as many times as when pressing space bar?

Hoping for unlimited times.  Are you thinking of duplicating the bullet object ten times, and just have each one fire off at that point?

A few other thought-path's I've gone down:

  1. Make the start point of the motion path for Object[B] relative to the current position of Object[A].  Can't find a way to do this.
  2. Be able to group/ungroup objects using triggers.

I'm also moderately adept at Javavscript, and happy to explore any option.

Simon Wood
Joanne Chen

Simon, have you ever considered to move the background pic instead of object[A]. In that case, you will be able to make oject[A] looks like moving around and fire unlimited times since both two objects actually are not moving.

Hi Joanne,

That's an interesting proposition.  I've already got this set up for the "background movement" using Javascript, and objects above the slide which move down to bottom.  When each object reaches the bottom, it calls a new object from the top again:

https://goo.gl/fu0FFB

First, click "GO".  Then "spam click" the Big, Medium, Small buttons a few times.  I've done all the difficult coding but had it all hooked up to buttons for testing.  The difficult part was having it select an object that wasn't currently animating down the screen on a motion path.

Simon Wood
Joanne Chen

I have another idea, it may not sound smart, but it can solve the unlimited fire issue. You should have variables for coordinates X&Y of object[A] , if you don't, just create them. Then create bullets in every coordinates(X,Y), add triggers to fire each bullet according to the position of object[A].

That is one option I had considered - but had hoped to avoid due to the time consumption.  With some software engineering experience, I recognise it as a solution that is not elegant at all.  However, it may be my only option.  There is additional work involved - all bullet objects would be hidden state before fire, and must return to hidden after fire.  Also, I would need to work in a mechanic to prevent the user from rapid firing on the same spot (I'll have to slow down their reload rate or something).

Interesting - it's a possible solution.  Thank you Joanne!

By the way - what do you think of the background effect I built?

Simon Wood

So, in my current configuration, I have 11 rows and 18 columns, which means making 198 bullet objects, and possibly copying javascript into each.  And that's just to allow one bullet per location on the screen!

Seems like an awful lot of work to me!  There must be some sort of other workaround.  Can Javascript talk directly to objects within Storyline?  I was curious about this earlier, even just to read the name of an object that called the trigger?

Joanne Chen

I am not familier with javascript although I use them too, but I don't think it can communicate directly with the position of objects in Stroyline.

198 bullets are quiet huge number, but you can save time for that work if you use the way below:

  1. Create a layer for each bullet, make layer timeline equal to the time seeing a bullet fire(let's say 0.25s?).
  2. Set a trigger to move the bullet when timeline starts. (Make sure the motion path long enough so that when you duplicate layers you don't need to adjust the lengh)
  3. Hide slide layer when timeline finishes
  4. Copy and paste to create the other 197 bullet layers. All you need to adjust in those layers are the position of the bullet objects and the layers's name of course.
  5. Set triggers to open layers when space bar is pressed on condition of each pair of  coordinates variables. Well here you will have 198 triggers but it won't be too difficult since you can duplicate the first trigger and modify the others.

Well, if you set the position of bullet precisely, it should look great. Hope this help.

BTW, I like your background effect. That's really a good idea!

This discussion is closed. You can start a new discussion or contact Articulate Support.