- Home /
How to Script "octopus swimming" movement?
I have an 3D octopus with movement animation that looks great: the body slightly coils as the legs spread out, and then the octopus thrusts forward as the legs come together. But this presents a problem in that the movement in unity should not be continuous; that is, the octupus movement should be: thrusts forward and then stops, thrusts forward and then stops, thrust forward and then stops, etc. which should be in timing with the animation.
I can make the model move at a set speed but I want to know how to incrementally move as I described above: move and then stop for a split second, move and then stop for a split second, etc.
Answer by surfrowen · Jun 12, 2016 at 07:00 AM
I'm still interested in how this could be scripted, however the easy work-around was to included the desired translation-movement into the animation.
Answer by vyonox · Jun 12, 2016 at 03:19 AM
Does the gameobject have a rigidbody? Are you using AddForce to move the octopus? In that case, try using ForceMode.Impulse. And use AddForce once every X seconds, synchronized with the octopus animation. And add some Drag to the rigidbody, that way it will automatically decrease the speed after every impulse.
If you are not using physics, then you will need to simulate the acceleration and drag by yourself. It's possible, but, unless you have a good reason, it's better to use a rigidbody.
Thanks vyonox, I am using a rigidbody. I'll give AddForce a try, I'm also going to try using animation curves and Vector3.Lerp to simulate the movement.
Your answer
Follow this Question
Related Questions
How do I stop moving when attacking? 1 Answer
Character Animator controller/movement 1 Answer
How to check in code when an animation is over? 1 Answer
run animation when should idle 1 Answer