本文整理汇总了C#中UnityEngine.BoxCollider2D类的典型用法代码示例。如果您正苦于以下问题:C# BoxCollider2D类的具体用法?C# BoxCollider2D怎么用?C# BoxCollider2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoxCollider2D类属于UnityEngine命名空间,在下文中一共展示了BoxCollider2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveVertical
public static float MoveVertical(BoxCollider2D box, float dy, out bool col)
{
col = false;
if (dy == 0.0f) {
return dy;
}
var min = box.bounds.min;
var max = box.bounds.max;
float ret = dy;
if (dy > 0) {
for (int i = (int)min.x + 1; i <= (int)max.x - 1; i += 1) {
var hit = Physics2D.Raycast (new Vector2 (i, max.y), Vector2.up, Mathf.Abs(dy), tileLayer);
if (hit.collider != null) {
col = true;
ret = Mathf.Min (ret, hit.distance);
}
}
} else if (dy < 0) {
for (int i = (int)min.x + 1; i <= (int)max.x - 1; i += 1) {
var hit = Physics2D.Raycast (new Vector2 (i, min.y), Vector2.down, Mathf.Abs(dy), tileLayer | ladderEndLayer);
if (hit.collider != null) {
col = true;
ret = Mathf.Max (ret, -hit.distance);
}
}
}
return ret;
}
示例2: Awake
void Awake()
{
sprite = GetComponent<SpriteRenderer>();
body = GetComponent<Rigidbody2D>();
col = GetComponent<BoxCollider2D>();
parentBalista = transform.parent.gameObject;
}
示例3: Start
// Use this for initialization
void Start()
{
rigid = GetComponent<Rigidbody2D>();
box = GetComponent<BoxCollider2D>();
esperando = espera;
anim = GetComponent<Animator>();
}
示例4: Start
void Start()
{
_spriteRenderer = GetComponent<SpriteRenderer>();
_boxCollider = GetComponent<BoxCollider2D>();
_isLaserVisible = isLaserVisibleOnStart;
ChangeLaserApperance ();
}
示例5: Awake
/*---------------------------------------------------- AWAKE ----------------------------------------------------*/
void Awake()
{
powerManager = GameObject.Find("GameManager").GetComponent<PowerManager>();
anim = transform.FindChild("Animation").GetComponent<Animator>();
effectorCollider1 = transform.FindChild("AreaEffectors").GetChild(0).GetComponent<BoxCollider2D>();
effectorCollider2 = transform.FindChild("AreaEffectors").GetChild(1).GetComponent<BoxCollider2D>();
effectorCollider3 = transform.FindChild("AreaEffectors").GetChild(2).GetComponent<BoxCollider2D>();
consoleViewImage = transform.FindChild("ConsoleView").GetComponent<SpriteRenderer>();
powerCost = GetComponent<Power>().powerCost;
GameObject fanDistance = transform.FindChild("FanDistance").gameObject;
float difference = Vector2.Distance(transform.position, fanDistance.transform.position);
effectorCollider1.size = new Vector2(difference-1, effectorCollider1.size.y);
effectorCollider1.offset = new Vector2(difference / 2, 0);
effectorCollider2.size = new Vector2(difference - 1, effectorCollider2.size.y);
effectorCollider2.offset = new Vector2(difference / 2, 1.7f);
effectorCollider3.size = new Vector2(difference - 1, effectorCollider3.size.y);
effectorCollider3.offset = new Vector2(difference / 2, -1.7f);
}
示例6: Start
// Use this for initialization
void Start () {
ac = this.gameObject.GetComponent<AttributeComponent>();
bc = this.gameObject.GetComponent<BoxCollider2D>();
pbc = GameObject.FindWithTag ("Projectile").GetComponent <BoxCollider2D>();
anim = (Animator)GetComponent(typeof(Animator));
meleeSys = (MeleeSystem)GetComponent(typeof(MeleeSystem));
}
示例7: Awake
void Awake()
{
_Animator = GetComponent<Animator>();
_BoxCollider = GetComponent<BoxCollider2D>();
_Rigidbody = GetComponent<Rigidbody2D>();
_AudioSource = GetComponent<AudioSource>();
}
示例8: Start
// Use this for initialization
void Start () {
animator = this.GetComponent<Animator> ();
boxCollider = this.GetComponent<BoxCollider2D> ();
audioSource = this.GetComponent<AudioSource>();
audioSource.clip = soundOnTouch;
}
示例9: Start
//private Animator animator;
public void Start()
{
// Components
moveController = GetComponent<EnemyMoveController>();
animationController = GetComponent<AnimationController>();
sprRend = GetComponent<SpriteRenderer>();
collider = GetComponent<BoxCollider2D>();
health = GetComponent<Health>();
player = FindObjectOfType<Player>();
//laser = GetComponent<Projectile> ();
//laserObject = GetComponent <Projectile> ();
//rigidbody2D.mass = 10;
distance = new Vector2(0, 0);
speed = new Vector2(0, 0);
isAgro = false;
rnd = new System.Random(Guid.NewGuid().GetHashCode());
t = 3 + rnd.Next(0, 3000) / 1000f;
teleporting = false;
teleportCD = 11;
temp = 0;
canTeleport = true;
facing = new Vector2(0, 0);
}
示例10: Start
void Start()
{
score=GameObject.Find("Canvas").GetComponent<GameManager>();
box=GetComponent<BoxCollider2D>();
scoreTrans=GameObject.Find("score100(Clone)").GetComponent<scoreTransformer>();
player=GameObject.Find ("Player").transform;
}
示例11: Start
/* deben hacerse todos los getcomponent y los valores que se quieran por defecto*/
void Start()
{
boxcollider2D = GetComponent<BoxCollider2D>();
colorpersonaje = (GameObject.FindWithTag ("Player")).GetComponent<Color_Personaje>();
spriterenderer = GetComponent<SpriteRenderer>();
//porAbajo = false;
}
示例12: Start
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>();
boxCollider = GetComponent<BoxCollider2D>();
timeSpentActive -= timeOffset;
isActive = false;
unactiveDuration = activeDuration + 2f;
}
示例13: Awake
protected virtual void Awake() {
// inputState = GetComponent<InputState>();
abductBody2d = GetComponent<Rigidbody2D>();
abductCollisionState = GetComponent<CollisionState>();
boxCollider = GetComponent<BoxCollider2D>();
}
示例14: Awake
void Awake()
{
scriptpersonaje =GameObject.FindWithTag ("Player").GetComponent <CambiaColor_CH>();
boxcollider2D = GetComponent<BoxCollider2D>();
spriterenderer = GetComponent<SpriteRenderer>();
ColoresBloque();
}
示例15: Start
// Use this for initialization
void Start()
{
selfCollider = transform.GetComponent<BoxCollider2D>();
colliderx = selfCollider.size.x / 2f;
collidery = selfCollider.size.y / 2f;
eventMng = GameObject.FindGameObjectWithTag("Manager").GetComponent<ClickEventManager>();
}