Game Development Reference
In-Depth Information
The boss should only be able to kill the player and enemies by squishing them
when he falls. To support this, create a new empty GameObject, call it
Boss Crush
Zone
, and make it a child of the
Boss
object. Give it a
Box Collider 2D
component,
and make it such that its size covers the bottom portion of the boss by setting its
Transform
position as
X: 0
,
Y: -0.175
, the
Size
fields to
X: 3.74
,
Y: 0.2
, and
set the
Center
to
X: 0
,
Y: 0.09
. It should now be aligned at the bottom-center, as
shown in the following image:
Create a new script called
BossCrushTrigger
, attach it to the
Boss Crush Zone
object, and code it up as shown in the following code:
using UnityEngine;
using System.Collections;
public class BossCrushTrigger : MonoBehaviour
{
public BossEventController bossController;
void OnTriggerEnter2D( Collider2D collidedObject )
{
if(bossController.currentEvent !=
BossEventController.bossEvents.fallingToNode)
return;
if(collidedObject.tag == "Player")
collidedObject.SendMessage("hitByCrusher");
}
}