コード例 #1
0
    /*
     ########################## 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);
    }
コード例 #2
0
 public void OnTriggerEnterNotify(CollisionBroadcaster trigger, Collider other)
 {
     if (other.tag == "Player")
     {
         if (trigger == entranceTrigger)
         {
             StartCoroutine(TravelingSequence(other.gameObject));
         }
     }
 }
コード例 #3
0
ファイル: GameController.cs プロジェクト: AboveTS/MultiPong
    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();
    }
コード例 #4
0
 public void OnTriggerExitNotify(CollisionBroadcaster trigger, Collider other)
 {
 }