Best way to make a game object have a "springy" toggle button feel, similar to a ballpoint pin
I have a tree object comprised of three sprites (top triangle, bottom triangle, trunk).
When a player touches the tree, I want it to compress all three sprites slightly, then have them spring open upwards on release. Touching again would reverse the state. Similar effect to pressing the top of a ballpoint pen like this: http://ecx.images-amazon.com/images/I/316cGqKsgcL._AC_UL320_SR258,320_.jpg
I've been trying it with springJoint2d and AddForce, but it can start to go (literally) sideways at points... plus I'm not sure how to make it stay at the "expanded" state.
Is there a simple solution for this?
I've attached the image of the tree for clarity, hopefully it makes sense. Thanks!
Answer by G4merSylver · Dec 22, 2015 at 07:50 PM
Relying on an sinus function might be helpful, I would create an script based animation inside an OnStayCollider and then relying on an coroutine(IEnumerator) yield return new waitforseconds() to shot the player up in sync.
Your answer
Follow this Question
Related Questions
2D ledge grabbing -1 Answers
(2D) Movement-Animation Problems 0 Answers
2D Dynamic Lights and Shadows 0 Answers
How can I create random butterfly flying over a random 2d path. 0 Answers