Disable the movement, the collider and the auto-fire (when initialized).We need to update “EnemyScript”, so it will: They should also be removed once they are completely off the screen. We said earlier that enemies should be disabled until they are visible by the camera. We highly recommend to avoid these methods. This means that we will not get the same behavior in the Unity editor and in a build (whatever the platform is). The problem is that these methods are also called when rendered by the “Scene” view of the Unity editor. They work like the Start() or Stop() methods (if you need one, simply add the method in the MonoBehaviour and Unity will use it). The basic idea of these methods is to execute a fragment of code when the object is rendered (or vice-versa). Note: why don’t we use the OnBecameVisible() and OnBecameInvisible() methods? Because they are broken. Yes! We finally have a functional “parallax scrolling” implementation. (Click on the image to see the animation) ![]() Otherwise, it will (predictably enough) not work. Remember to enable the “Is Looping” property of the “ScrollingScript” for the 0 - Background in the “Inspector” pane. Indeed, the backgroundPart is the exact representation of what is happening in the scene. Finally, we put it at the last position of backgroundPart list. When it’s the case, we change its position to be after the last (rightmost) child. We test if it’s completely outside the camera field.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |