/* ########################## Other ########################## */ public virtual void ReAdjust() { // collisionDetection var targetCollisionBroadcaster = target.GetComponent <CollisionBroadcaster>(); // ######### stop if same target if (targetCollisionBroadcaster != null && targetCollisionBroadcaster == currentCollisionBroadcaster) { return; // should be same target (no setup needed) } // ######### detach old target if (currentCollisionBroadcaster != null) { currentCollisionBroadcaster.unsubscribe(this); } // ######### setup new target currentCollisionBroadcaster = target.GetComponent <CollisionBroadcaster>(); currentCollisionBroadcaster.subscribe(this); // setup base rotation of camera Quaternion targetRotation = this.target.transform.rotation; defaultOffsetGround = targetRotation * (new Vector3(0, -1, 2).normalized *distance); defaultOffsetAir = targetRotation * (new Vector3(0, -1, 5).normalized *distance); }
public void OnTriggerEnterNotify(CollisionBroadcaster trigger, Collider other) { if (other.tag == "Player") { if (trigger == entranceTrigger) { StartCoroutine(TravelingSequence(other.gameObject)); } } }
void Start() { SpawnPaddles(_paddleCount); ball = Instantiate(ballPrefab, transform); CollisionBroadcaster cb = ball.AddComponent <CollisionBroadcaster>() as CollisionBroadcaster; // Subscribe to the OnCollision2D event of the ball to prevent excessive recomputation of the ball angle cb.collisionDelegate = OnBallCollision; ResetBall(); CalculateHitAngle(); }
public void OnTriggerExitNotify(CollisionBroadcaster trigger, Collider other) { }