The spike block is the only block that can immediately kill the player. Upon collision, the audio is triggered, the cool screen shake animation is played, and some blood is splattered out onto the screen. Just before the blood particle is activated, its transform is positioned to the point of impact. Like the other obstacles, the Spike block has a spotlight and a particle system. Each are their own separate gameObject to allow for easy modification. The spike block has no animation, as it just sits idle awaiting the player collision. The obstacle itself has no awareness of the player until collisions occur, of course there could be a reference to the player script so that it does not have to be retrieved during collision. I will have to see which is better overall.
0 Comments
Here is one of the obstacles from my slowly developing game "Blind Swipe" (temp name because names are hard). This is the BounceBlock. All Obstacles in the game inherit from Obstacles base class. This allows any small general changes to be made to each block without typing a bunch of code in each one. It also allows for easy Object collection when I want to do any manual scene cleaning. The BounceBlock Parent is an empty GameObject with an Animator, this allows me to use an animation to scale the size of the of the object when the player collides with it; also I can make changes to the child graphic, without the need to also alter the animation. The child graphic is a Sprite with an Animator that loops through a few spites to simulate the 'bounce' look - which is not affected by the Parents scale animation. So again, I can make changes to the graphic without altering the parent. The graphic has two children, a sprite 'spotlight' and a particle system. The spotlight is the green you seen behind the block, I can edit and scale or make any modifications to this graphic without affecting the block graphic or the parent. This makes modifications really easy. The particle system is triggered when the player collides, and shoots out little blobs that are similar to the spotlight graphics. The bounce count will call Losing() on the player to end the game and trigger all the GameOver activities that happen when the player loses. The code is fairly simple: BounceBlock.cs
|
AuthorDavid Jerome ArchivesCategories |