Unity Session 3
In today's session we continued the world interactions but this time it was damage zones and enemies.
First we added a damageable zone sprite from the asset and gave it a collider just like collectibles only difference was that the life was subtracting from the charachter as it passes through zone. This was easy past because we did this before and in script editor only one thing was supposed to change that was health +1 to -1 that was it. We tested it and it was successful.
We moved on to enemies afterwards. We added a robot png to asset folder from the handout files and made it sprite. We made a new script in script folder named it enemycontroller because we had to animate enemy into scene and programme it to take one health on interaction with charachter. We also had to animate robot to move vertically and horizontally on its own. We programmed that too and also added health decreasing script to it and then tested it. It worked and we moved forward to Animation.
Animation was a fun part because we are familiar with keying animation it was easy to understand. We made a new animation folder in asset and saved out trial animations in it. We added two trial animations to it one of rotation and other of position.
We then learned about animator which is like a node based editor in which a different animated clip has a different node and we can play around with settings like what clip to start when game initiates. That clip is called default clip. Then we learn how to make transitions from animation to other and how it works.
Then in asset folder we had given bot animated frames we just had to pick left four and dragged it onto the timeline it automatically takes its position we just had to adjust our frame rate according to us. We did this for all of his moments like left, right, up, down. Thereafter, we learned how can we blend this animation into one mechanism which decreases gameload because 4 transition in one node does not make any sense. We used a BLEND TREE in which we can add all of our directional animation. It is also helpfull in providing function of which directional animation to play when interacted. In inspector window we set blend tree to 2D simple directional so it only resonates in vertical or horizontal axis. We added 2 parameters to it MOVE X and MOVE Y that will have horizontal or vertical move amount. We added motion fields through inspector . There were 4 motion hence 4 motion fields and added our animation onto it.
We changed their motion of corresponding direction like.
- Left : Pos X = -0.5 Pos Y = 0
- Right: Pos X = 0.5 Pos Y = 0
- Up: Pos X = 0 Pos Y = 0.5
- Down: Pos X = 0 Pos Y = -0.5
Comments
Post a Comment