Week 4: Move/Rotate Timer & GUI Features
This week, I further updated the TransformObject script to include a timer that smoothly caps each transformation. This made the flags' reset times much more predictable and made them respond more easily:
The timer t updates constantly but is reset to 0 when each transform method is called from a trigger. I also have those functions take a parameter for the duration of the transformation. I also moved several variable declarations from Awake into these method calls for efficiency (they are only used if the method is called).
I also fixed the issue I had last week where dynamic objects would keep moving unexpectedly even after they are set to kinematic. This was happening because they retained velocity applied onto them while they were dynamic (specifically when I mentioned that the flag was not deactivating because the gap between the current and target positions weren't close enough, or when an object would continue rotating because it had retained torque).
These were fixed by both implementing the timer and setting the respective velocity types to 0 before transforming the object, to make sure it is only the code affecting their movement while the objects are set as kinematic.
I also changed the transform method calls in the Trigger script to reflect the timer implementation. Here's the Move call as an example:
I found while working that it was somewhat tedious to test the actual movement of moving objects. Rotating objects was easier because they are simply rotated to a certain degree position, but trying out movement called for a lot of trial and error.
Therefore, I thought it would be nice to be able to see a projected position of these objects' transformations in the editor. I was given code to draw a basic wire cube, and through trial and error (and learning what a Matrix was) I made a version of this to project a rotating object.
To do that, I:
- Added a check for if the object had a child (some rotating platforms had a child with the actual sprite renderer but the parent transparent so I could appear to change the anchor point of the object).
- Set the matrix for the wire cube according to the transformations I would need for it.
The parent-child version is particularly interesting here, since I used the scale of the parent to set the matrix, but used the child's scale to draw the actual cube. The scale of the child is set to (1, 1, 1) and only changed scales of the parent object to prevent unexpected results.
I wanted to project a colored & low opacity version of the actual sprite renderer of the object, but for now I figured it still worked (and was cheaper processing-wise to run the editor) to simply draw a rectangle where the object would transform to instead.
Here's what the Rotate and Grow portions of the onDrawGizmos method look like (this method is used only in the Unity editor for GUI purposes and isn't included in builds by using #if UNITY EDTOR):
Here's what this looks like in the editor:
Notice the small text next to objects set to rotate that shows their target rotation!
Here's a test featuring a changed playground and the new timer:
I also wanted to look at animated & rule tiles, so I began importing the tiles I've been working on into the project to use later:
It's sort of a long process, but it should be more convenient to set up rules for some tiles and simply auto-paint them in rather than switching tiles for each area and doing this manually.
I also made a new scene to make discoveries and test these new mechanics. My goal for this is to find interesting quirks and things to do with the mechanics so I can make a better level later (those GUI changes I made will really help with this process!)
In summary, this week I learned about the OnDrawGizmos method and learned that timers can be useful as a value for Lerp to make sure it ends when intended. I also started adding tiles as assets into the project.
Over this upcoming week, my goal is to make those play discoveries and possibly get some external feedback for them. I'd also like to get a start on another level's tileset (which I started this week but unfortunately lost all my progress due to an ill-timed update from my computer). See you then!
ECK-423
Level 2 of ECK-423 (Discontinued for now)
Status | In development |
Author | Boltcry |
More posts
- Week 12: Revising Level 2Apr 07, 2023
- Weeks 9-11: Level 2 Design (Part 2)Mar 29, 2023
- Week 8: Level 2 Design (Pt 1)Mar 08, 2023
- Week 7: Serialized Transform ClassFeb 28, 2023
- Week 6: Checkpoint SystemFeb 21, 2023
- Week 5: Play DiscoveriesFeb 14, 2023
- Week 3: Code optimizationJan 31, 2023
- Week 2: Move/Rotate MechanicJan 23, 2023
- Week 1: Organization & Controller UpdatesJan 17, 2023
Leave a comment
Log in with itch.io to leave a comment.