Forum Discussion
Object continuously jump upward when pressing a key
You can just select the object and create a motion path animtion directed upward. Make it short and brief (e.g., 25px long, 0.25 sec duration). Change the settings to no direction easing, and make it relative to starting position. Create a move trigger attached to the keypress you desire and executing the motion path on the movable object.
- KelvinLabos27 days agoCommunity Member
Thanks! And how I add the gravity pulling down the object when the key is not pressed?
- Nathan_Hilliard27 days agoCommunity Member
If all you need is up and down, then you could add a downward motion path to the object that plays on a timer which continually moves it down unless the key is pressed. You could make a timer in JavaScript or by creating and repeatededly showing a layer with a short timeline (maybe 0.25 to 0.5 sec) that triggers the downward movement (with a matching duration) on timeline end. You can also see the older post at Create a Timer for Storyline Any Version | Articulate - Community or try searching the forums for some ideas.
If also trying to move horizontally, I believe Storyline may play the motion paths sequentially, meaning one path will finish before the next begins, with leads to a choppy stair-stepped effect. I only did some brief testing. To get better and smooth results (like arcs), you may have to resort to JavaScript and GSAP to generate you movements. (see also: Use keyboard keys to move a shape on a slide | Articulate - Community).
For excellent results, you could also utilize a physics engine like matter.js to handle gravity and collision issues. For simple examples in SL, see
Integration of physic engine in Storyline (test) | Articulate - Community and
Plinko game ideas | Articulate - Community
This would look great, but require a lot more work.