playMaker

Author Topic: Suggestions for the best way to do this?  (Read 3547 times)

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Suggestions for the best way to do this?
« on: May 17, 2015, 10:48:23 AM »
I have 20 cubes in a line that move up and down in a looping sine-wave pattern. So each cube is just moving up and down on the Y axis, offset a little from the one before it. However, I want the level to start with the cubes at rest on the ground, and when the user clicks a cube, that cube moves into the correct up/down motion to make the standing-wave motion.

Any idea how to do this? I know how to make a cube go up and down in a loop, but the challenge is if the user can click the cubes in any order, how to get them to move to form the wave.

« Last Edit: May 17, 2015, 10:56:27 AM by indeed »

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Suggestions for the best way to do this?
« Reply #1 on: May 19, 2015, 09:32:26 AM »
Hi, sorry to bump this but I'm still struggling. To the more expert users, does this seem like a complex non-trivial problem? Or am I missing something obvious?

flora

  • Playmaker Newbie
  • *
  • Posts: 47
Re: Suggestions for the best way to do this?
« Reply #2 on: May 19, 2015, 11:48:05 AM »

hello  :)

may be you could play with the offset dynamically, set it up as a variable and control it anyways you want ...
like : if i click on the cube => "offset=0" => go to next cube => "offset=offset+1" => go to next cube => etc ...


indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Suggestions for the best way to do this?
« Reply #3 on: May 19, 2015, 03:20:03 PM »
Hi thanks, this would work to generate a wave, but what I'm struggling with is how to make that happen if the cubes are clicked in a random order by the user, one after the other. The entire wave is not triggered at once.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Suggestions for the best way to do this?
« Reply #4 on: May 21, 2015, 06:56:41 AM »
Hi,

 I would look for a spline asset that would align gameobjects on a spline. Plenty of solutions on the asset store.

Flora's solution is good too, since you want a sin animation, some simple math combined with offset will give you a very precise control over several cubes to behave as you want.


Bye,

 Jean

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Suggestions for the best way to do this?
« Reply #5 on: May 21, 2015, 08:45:15 AM »
Hi! That's an interesting idea about the spline. I actually have it animated in the wave correctly in Cinema 4D, and this imports fine into Unity via legacy animation.

The problem is less the wave itself, and more how to make each cube "join" the wave motion, when clicked at random times, one at a time. So in theory, only half of the cubes could be in the "wave" with the other un-clicked cubes still on the ground.

Tedthebug

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Suggestions for the best way to do this?
« Reply #6 on: May 22, 2015, 12:54:17 AM »
ok, I will admit up front that I'm a noob so sorry if this wastes your time.  :)

if I'm getting this right you want each block to move up off the ground once it is clicked & join into the sine wave that the others are forming?  so the first block moves up & down & then as more are clicked a wave pattern appears?

what if the blocks were duplicated with one lot not rendered & they start the wave motion while the visible blocks are sitting on the ground.  As one on the ground is clicked it rises up until it collides with the invisible block moving above it at which point the mesh is activated on the invisible one & the one that was clicked is destroyed?  that would give the appearance of it moving into the line.  You may need to delay the destruction a bit so it is a cleaner replacement.


indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Suggestions for the best way to do this?
« Reply #7 on: May 22, 2015, 07:53:53 AM »
Whoa, good idea! Thanks! I'll try it