Twin Robots – dev video 02

A new video about Twin Robots!

Watch the video on Youtube

You can see some new animations going on: looking back / forward while hanging on a ledge to have a clearer view of where are you going to jump! Also, you can now push your brother around… :D

Not shown on this video, but you can now take control of any of the two brothers, in fact it will be mandatory to be able to complete the levels! Good brothers join forces to win!

The hanging-back / hanging-up animation got me scratching my head for a while so here is a Unity tip (you may find it useful, I know my future self will!): If you have an animation clip set to “Clamp Forever” and then you want to play it backwards, make sure you set the current time of the animation to its last frame before reversing the clip.

For example: when hanging on a ledge if you press the “back” key, the “hang-back” animation plays, making the robot look back. This animation is set to “Clamp Forever” since I want it to stay at the last frame. When the player releases the “back” key, I play this animation backwards to return to normal “hanging” position.
To play an animation backwards, you just set its speed to -1 and then play as usual:

robot.animation["hangBack"].speed = -1;
robot.animation.Play("hangBack");

The trick here is that you need to set the current time of the animation to its last frame or it will play backwards from that “last frame Clamped Forever”. This means that if you hang back, stay there for 3 seconds, and then release the button, you won’t see the reversed animation playing until 3 seconds later.
So, you’ll use this for playing the animation backwards:

robot.animation["hangBack"].time = robot.animation["hangBack"].length;
robot.animation["hangBack"].speed = -1;
robot.animation.Play("hangBack");

And if you now want to play it forward, set the current time to 0, the speed to 1, and play the animation.

Add a Comment