Build a reusable shake manager for adding screen shake effects to your games. You’ll learn how to work with Unity 5’s UI RectTransform anchor position and randomly apply values to the x and y positions for a specified duration of time. When the shake is over you’ll restore the original values to the RectTransform.
- [Voiceover] Now it's time for us to add…some effects to our battle…to make it a little bit more visually appealing.…In order to do this, let's go…into our battle system folder,…into the scripts folder,…and let's create a new C# script,…and we're gonna call this ShakeManager.…And now let's open up the ShakeManager…inside of MonoDevelop.…What this class'll do is take a RectTransform,…and over a certain period of time,…assign random values to it…to give the impression that it's shaking.…To do this, let's add a few properties…to the top of our class.…
We'll start with private RectTransform,…and we're gonna call this target.…Next, we'll have a private float,…and we're gonna call this duration,…and then we'll add another private float,…and we're gonna call this strength.…Next, we'll add another private float,…and we'll call it timeElapsed,…and we'll set this to equal zero.…And then, finally, let's add a new…private Vector2, and we'll call this original position.…
Next, let's create the method we'll use…to trigger the shake.…
- Preparing the user interface
- Creating game and message windows
- Building a battle window
- Adding a monster and action buttons
- Creating an actor class
- Adding player and monster attack actions
- Triggering battles from the map
- Ending a battle
- Cleaning up the battle and attack systems
- Rewarding the player
Skill Level Intermediate
1. Preparing the UI
2. Message Window
3. The Battle Window
4. Actor Classes
5. Battle Actions
6. Cleaning Up Combat
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.