Master Of Animation, Games & Interactivity
Master Of Animation, Games & Interactivity

I have been working on setting up some interactive objects in the game this week.
I started out with an interactive door. As usual, I had to go through a few tutorial to figure out setting up a trigger-able  object. By the end of the class, I did manage to set it up. The door opens when the character walks to infant of it. It’s triggered by the colliders.
I thought ok at least I get to trigger it open now and had a naive thought of “well, that shouldn’t be too far away from “triggering to action with interaction key.” I was so wrong.
Took me another 3 days just to find the workable tutorials (had to combine a few of them, back and forth), kept getting errors (misspelling stuff a lot of the time). Finally get the door to open by interaction key.
Then I moved on to creating an indication when character is close to an interactive object. This was slightly easier compared to the door set-up.
After the long hours fighting with the DoorOpener, I had a clearer idea of the structures of C#, and the reasons sometimes the steps on the tutorials didn’t work for me. For example, I set-up my character controller differently from the tutorials, so I had some how first figure out what to add in, an extra bool or void codes, to bring up the elements the tutorial were working with. It was an issue for me because I had a hard time figure out what I was missing in my character controller and the ones in the tutorials.
So back to the interactive object indication, after I had the experience with my “auto-door”. I figured the indications should work the same way: with a collider and then trigger to set up active sprite when get close to the object collider.
I tried out my assumption with a still bush sprite, it worked! Then I made an icon spinning clip to swap with the bush sprite.
Then I figure, ok, I might as well make some other use of the tigger coding. I decided to put in some trigger-fly-away pigeons. The code worked all fine, the pigeons  fly away smoothly BUT! They popped back on when the character left the trigger collider, and also the fly-away clip would stop playing, when the player character left the trigger collider area, therefore the pigeon flew into the air and disappear half way before leaving the scene! Again, after another day of head-bang-on-wall, I discovered in stead of setting everything on an empty game object, I had to add the trigger code and 2D collider on the start up animation. So when it’s triggered, the start up would set to false, this way, it will also set the trigger collider to false, and also activate the flying-animation. No more popping back pigeons.
https://www.youtube.com/watch?v=1Sa7IdsPIac&feature=youtu.be

About This Work

By Gin Lin
Email Gin Lin
Published On: 18/10/2020