Adding to what we were taught last week about movement, this week we started applying physics to objects and seeing how it caused them to interact. We started off by adding physics to the character in order to make it look like the object is accelerating rather then going straight from 0 to the desired speed.
 |
Code to apply force in direction of movement |
We also learnt about interpolation. This is the process of moving an object smoothly between 2 points so it hits every point in between them, rather than jumping from one to the other. In order to do this we needed to learn about 'Lerp' which interpolates between the two points for us.
 |
Lerp code snippet |
Once we had learnt the basics and got a system set up, we started to use co-routines in the interpolation. This is like a separate method that can only progress to the next step once the previous ones have been completed so can be held waiting for a long time until conditions are fulfilled. We used an initial co-routine to send the object from point A to B, then set up a reverse system to move it back.
 |
Initial and reverse co-routines |
 |
Shot of interpolation in action |
The last thing we were taught was how to make different objects act like they were made of different materials. For example, two materials I made were metal and ice which, when applied to an object, caused it to interact with the environment differently. The metal material had high friction and very low bounciness which made the object slow and heavy whilst moving. The ice material also had low bounciness but in contrast, next to no friction. This caused it to slide around and have other objects slide off of it. Physics materials will be useful if independently moving objects interact because they will make the collision feel more realistic based on the material they're designed to be made of.
No comments:
Post a Comment