本文整理汇总了C#中UnityEngine.CircleCollider2D类的典型用法代码示例。如果您正苦于以下问题:C# CircleCollider2D类的具体用法?C# CircleCollider2D怎么用?C# CircleCollider2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CircleCollider2D类属于UnityEngine命名空间,在下文中一共展示了CircleCollider2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
currRadius = 0f;
circleCollider = GetComponent<CircleCollider2D>();
circleCollider.radius = currRadius;
Instantiate(shockwaveFXPrefab, transform.position, Quaternion.identity);
}
示例2: Awake
void Awake()
{
transform = GetComponent<Transform>();
Gravity = GetComponent<CircleCollider2D>();
_player = GameObject.FindGameObjectWithTag("Player").GetComponent<LookAtMouseMove>();
}
示例3: Start
public void Start()
{
findedEnemys = new List<BaseEnemy>();
_player = transform.parent.GetComponent<Player>();
_collider = transform.GetComponent<CircleCollider2D>();
_baseRadius = _collider.radius;
}
示例4: IgnoreCollisions
public void IgnoreCollisions(CircleCollider2D coll)
{
foreach (Transform child in transform)
{
Physics2D.IgnoreCollision(child.GetComponent<BoxCollider2D>(), coll);
}
}
示例5: Awake
void Awake()
{
rigidbody = GetComponent<Rigidbody2D>();
body = GetComponent<PolygonCollider2D>();
feet = GetComponent<CircleCollider2D>();
health = GetComponent<Health>();
standing = body.points;
crouched = new Vector2[standing.Length];
grounded = false;
onWall = false;
upSlope = false;
downSlope = false;
int min = 0;
for (int i = 0; i < standing.Length; i++)
{
if (standing[i].y < standing[min].y)
min = i;
}
for (int i = 0; i < standing.Length; i++)
{
float newY = (standing[i].y - standing[min].y) * 0.5f + standing[min].y;
crouched[i] = new Vector2(standing[i].x, newY);
}
}
示例6: IsOverLappingWithAnother
private bool IsOverLappingWithAnother(CircleCollider2D col){
Collider2D[] colliders = FindObjectsOfType<Collider2D>();
float checkGap = 0.1f;
int ySign = 1;
foreach(Collider2D testCol in colliders){
if (testCol.gameObject != col.gameObject){
for (int i = 1; i <= 2; i++){
for (float x = col.transform.position.x - col.radius; x <= col.transform.position.x + col.radius; x += checkGap){
Vector2 checkPoint = new Vector2(x, ySign * Mathf.Sqrt(Mathf.Pow(col.radius,2) - Mathf.Pow((x - col.transform.position.x ),2)) + col.transform.position.y);
Debug.Log("PIE");
if (testCol.OverlapPoint(checkPoint)){
return true;
}
}
ySign = -1;
}
}
}
return false;
}
示例7: Start
// Use this for initialization
void Start () {
rbody = GetComponent<Rigidbody2D>();
collider = GetComponent<CircleCollider2D>();
selectorRenderer = selector.GetComponent<SpriteRenderer>();
selectorRenderer.enabled = false;
charController = GameObject.FindWithTag("Player").GetComponent<CharacterController>();
}
示例8: Awake
// Use this for initialization
protected override void Awake()
{
base.Awake();
vfx = GetComponent<ParticleSystem>();
coll = GetComponent<CircleCollider2D>();
effector = GetComponent<PointEffector2D>();
}
示例9: Awake
void Awake()
{
spring = GetComponent<SpringJoint2D>();
rigid2d = GetComponent<Rigidbody2D>();
collider2d = GetComponent<CircleCollider2D>();
catapult = spring.connectedBody.transform;
}
示例10: Start
// Use this for initialization
public override void Start()
{
base.Start();
exploded = false;
explosionRadius = gameObject.GetComponent<CircleCollider2D>();
}
示例11: charge
void charge()
{
numShots = 0;
if (chargedShot==null) {
charge_anim.SetBool("charge", true);
chargedShot = Instantiate (gun.bullet, gun.firingLocation.position, Quaternion.identity) as Rigidbody2D;
chargedShot.gameObject.SetActive(true);
chargedCollider = chargedShot.GetComponent<CircleCollider2D>();
chargedCollider.enabled = false;// disable the collider first
script = chargedShot.GetComponent<BulletScript>(); // assign the script
if (master.shipMode){
chargedShot.rotation = 90; // 270 degrees means facing north
}
else {
master.setCharge(1f); // set 'charging' layer to activate
}
chargedShot.GetComponent<SpriteRenderer>().enabled = false;
} else { //if (chargeLevel<=totalCharge)
Vector3 size = chargedShot.transform.localScale;
chargedShot.transform.localScale = new Vector3(size.x*1.5f, size.y*1.5f, 1f);
script.damage = script.damage*2;
}
// make the charged shot stronger
chargeLevel++;
}
示例12: Start
// Use this for initialization
void Start()
{
col = GetComponent<CircleCollider2D>();
men = GameObject.Find("Menu");
win = new Window(new Vector4((Screen.width - 100)/2,(Screen.height - 100)/2, 100, 100));
script = men.GetComponent<Menu>();
}
示例13: Start
void Start()
{
//moveVector = new Vector2(;
col = GetComponent<CircleCollider2D> ();
anim = GetComponent<Animator> ();
//test arguments
}
示例14: Start
// Use this for initialization
void Start () {
particles = GetComponent<ParticleSystem>();
circleColider = GetComponent <CircleCollider2D>();
animator = GetComponent<Animator>();
timeToRespawn = timeToRespawn + Random.Range ( timeToRespawn * 0.96f , timeToRespawn * 1.04f);
}
示例15: Start
public void Start()
{
// 30 rays at minimum
var alpha = Mathf.Acos(Resources.MinSizeOfEnemy / 2 * Radius) * Mathf.Rad2Deg;
_minAngle = 180 - 2 * alpha;
_minAngle -= SkinRadius;
_detectedEnemies = new List<BoxCollider2D>();
_sonarCollider = GetComponent<CircleCollider2D>();
if (_sonarCollider == null)
Debug.LogError("Sonar Collider component has not been assigned");
if (Type == Resources.FriendlyReconType.Sonar)
{
_sonarDetection = true;
_sonarCollider.radius = Radius;
_sonarCollider.isTrigger = true;
}
_circularDetectionAngle = 0f;
_angleBetweenRays = 360f / NumberOfRays;
_backgroundManager = GetComponent<FriendlyBackgroundManager>();
if (_backgroundManager == null)
Debug.LogError("Background Mananger is null");
}