![]() |
| Cyan debug line in physics scene |
Showing posts with label Interpolation. Show all posts
Showing posts with label Interpolation. Show all posts
Wednesday, 7 October 2015
Physics Debugging and Manual Interpolation
Following up from Monday's session, we implemented debugging to see how Unity controls the change in velocity. To do this I added a max speed which, when reached and passed, lowered the speed back below the maximum. The speed was not lowered to a constant however and continues to increase meaning this process happens very quickly multiple times a second. To show this, a line is set to be drawn that shows the direction and magnitude of force. This line appears to vibrate/shake rapidly when the player moves which is the program constantly adjusting the velocity.
Another thing I added to this weeks work was creating manual interpolation rather than have it bounce back and forth of it's own accord. To do this I only needed to tell the co-routine that it should only operate when a specific button is pressed and held. This sort of mechanic could be used for moving platforms and can even be set up to activate the interpolation upon a single button press, allowing you to make elevators.
Monday, 5 October 2015
Physics and Interpolation
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.
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.
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.
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.
![]() |
| 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.
Subscribe to:
Posts (Atom)




