- Home /
iTween input with spring
I am trying to move a selected block the user grabs along one axis (x) when they push the a or w keys, while the key is pushed it should slide along and then when it is released, I would like it to spring in to place where they stopped pushing the key.
I am having difficulty with itween, it keeps moving the block in steps instead of smoothly.
if(Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
{
float horizontal = Input.GetAxis("Horizontal");
iTween.MoveUpdate(gameObject, iTween.Hash("x", horizontal, "isLocal", true));
}
I know, simplistic but I am really not sure how to get the effect I desire.
Answer by ZenithCode · Oct 14, 2012 at 09:53 AM
Add this to your hash: "easetype", iTween.EaseType.easeOutSine to solve your first problem.
I know the ease type, not worried about it right now. I need it to stop stopping.
It is not moving smoothly because you are calling iTween in Get$$anonymous$$ey. This will restart iTween until player releases button. As a test, try and quickly tap the key once, and see if the behavior changes.
What you can try now is remove your code and try out the iTween Visual editor which is available on Unity AssetStore.
Check this quick tutorial if you need help to get started. http://www.youtube.com/watch?v=gBZeeDU962A
Also, it is not because of get key because if I just use getting the key to flip a bool and move constantly if the bool is true, it still inches its way across the screen. How do I just make it go one direction smoothly till you let go of the key?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Limit distance from start while using iTween 0 Answers
Distribute terrain in zones 3 Answers
How to prevent an animation from triggering more than on due to fast clicking? 2 Answers
iTween Path swap 2 Answers