My work today consisted in making a functioning trap for the moth. The trap represents a spider’s web, that can trap the moth until it is destroyed or the player gets “eaten” by a spider.
This is a visual representation of the web:
The octagone is a placeholder for the actual web, which will later be implemented in the project.
In order for the challenge to be more realistic, if the player does not see the web in time and gets caught in it, the sprite will be automatically be dragged to the middle of it and will have ~3 seconds to escape. I am really pleased about how it ended up.
Coding wise, I had to implement a state – the “caught” state, which unables the movement unless you use a power up when it goes back to the “movement” state. I made the web destroyable by the “dodge” abilty and in the future it will be destroyable also by the sonar, of course, under some conditions.
I think the hardest pract of this task was configuring out the state machine itself and how to make use of it. The coding was a medium effort because I had to do some documentation regarding classes in unity and some variables. Having Jacob as my Lead Coder is a great thing because he is far more experienced than me and can help me with some information that might be hard to understand at a first look.
Testing it worked as a charm. It took me 4-5 tries but it was more like tweaking the code rather than trying to rewrite it or changing it. We already had some scripts for the failure state or the “moving to the middle” (see power up flower for reference) so I was able to make use of those, making it even more easier for me to understand how to make the trap fully workable – with the stun and the destroyable object.
I stated above that I am pleased of the result because it is working as intended, everyone tested it and was also pleased by the result and I am eager to start on my new task. Needless to say – It’s a trap!