Back to Blog
That is where the trigger logic deletes its own GameObject. ![]() The homemade physics simulation is not just the movement in FixedUpdate() it also encompasses the reaction when the ball hits a wall.ĭeep within the OnTriggerEnter() callback is a Destroy() operation. As soon as the ball starts moving, the information about initial velocity is lost. We are reusing the same variable for two slightly different purposes. It doesn’t look like much, but on closer inspection, we see that the ball has a velocity that is used both by the designer to set the initial velocity vector of the ball, and by the homemade physics simulation to keep track of what the current velocity of the ball is. Let’s look at a simple example as shown in the image above. It’s a principle that you can apply to a code base of any size. If applied correctly you should be able to give short answers to the questions, “what does a particular class do?” as well as “what does it not do?” This makes it easy for every developer on your team to understand what the individual classes do. Let’s see how we can split them up by working from what’s called the Single Responsibility Principle, which stipulates that each class should handle one single thing. ![]() If this was a game in actual development, you would see the individual MonoBehaviors grow larger and larger.
0 Comments
Read More
Leave a Reply. |