Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        setCameraTarget(target);
        MoveToTarget();

        collision.Initialize();
        collision.UpdateCameraClipPoints(transform.position, transform.rotation, ref collision.adjustedCameraClipPoints);
        collision.UpdateCameraClipPoints(destination, transform.rotation, ref collision.desiredCameraClipPoints);

        collision.CheckColliding(targetPosition);
        positionSettings.adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPosition);
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        //moving
        MoveToTarget();

        //rotating
        LookAtTarget();

        //Cover
        CoverCam();

        collision.UpdateCameraClipPoints(transform.position, transform.rotation, ref collision.adjustedCameralClipPoints);
        collision.UpdateCameraClipPoints(destination, transform.rotation, ref collision.desiredCameraClipPoints);

        //draw debug lines
        for (int index = 0; index < 5; index++)
        {
            if (debug.drawDesiredCollisionLines)
            {
                Debug.DrawLine(targetPosition, collision.desiredCameraClipPoints[index], Color.white);
            }
            if (debug.drawAdjustedCollisionLines)
            {
                Debug.DrawLine(targetPosition, collision.adjustedCameralClipPoints[index], Color.green);
            }
        }

        collision.CheckColliding(targetPosition); //using raycasts;

        position.adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPosition);
    }
Ejemplo n.º 3
0
    void FixedUpdate()
    {
        // moving
        MoveToTarget();
        // rotating
        LookAtTarget();
        // player input orbit
        OrbitTarget();

        collision.UpdateCameraClipPoints(transform.position, transform.rotation, ref collision.adjustedCameraClipPoints);
        collision.UpdateCameraClipPoints(destination, transform.rotation, ref collision.desireCameraClipPoints);

        // draw the debug lines
        for (int i = 0; i < 5; i++) // loop through clip points
        {
            if (debug.drawDesiredCollisionLines)
            {
                Debug.DrawLine(targetPos, collision.desireCameraClipPoints[i], Color.white);
            }
            if (debug.drawAdjustedCollisionLines)
            {
                Debug.DrawLine(targetPos, collision.adjustedCameraClipPoints[i], Color.green);
            }
        }

        collision.CheckColliding(targetPos); // using raycasts here
        position.adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPos);
    }
Ejemplo n.º 4
0
    void FixedUpdate() // NEW
    {
        //moving
        MoveToTarget();
        //rotating
        LookAtTarget();
        //player input orbit
        OrbitTarget();
        MouseOrbitTarget();

        collision.UpdateCollisionHandler(destination, targetPos);

        position.adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPos);
    }
Ejemplo n.º 5
0
    private void FixedUpdate()
    {
        FollowTarget();

        if (!character.isLockedOnEnemy)
        {
            HandleRotationMovement();
        }
        else
        {
            HandleLockedRotation(lockSpeed);
            HandleTargetHUD();
        }

        collision.UpdateCameraClipPoints(cam.transform.position, cam.transform.rotation, ref collision.adjustedCameraClipPoints);
        collision.UpdateCameraClipPoints(destination, cam.transform.rotation, ref collision.desiredCameraClipPoints);

        collision.CheckColliding(targetPos);
        adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPos);
    }
Ejemplo n.º 6
0
    void FixedUpdate()
    {
        //moving
        MoveToTarget();
        //rotating
        LookAtTarget();
        //player input orbit
        if (!editingSettings)
        {
            if (orbit.allowOrbit)
            {
                MouseOrbitTarget();
            }
        }

        if (useCollision)
        {
            collision.UpdateCollisionHandler(destination, targetPos);
            position.adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(targetPos);
        }
    }
Ejemplo n.º 7
0
    void FixedUpdate()
    {
        //Debug.Log("holdTime: " + holdTime);
        //Debug.Log("adHold" + adHold);
        //Debug.Log("adHoldLong" + adHoldLong);
        if (enableControl)
        {
            if (holdTime - 5.0f > 0)
            {
                adHoldLong = adHold;
            }
            if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
            {
                if (adHold != 0)
                {
                    holdTime += Time.deltaTime;
                }
                return;
            }
            if (Input.GetKey(KeyCode.A))
            {
                if (adHold == 1)
                {
                    adHoldLong = 0;
                    holdTime   = 0;
                }
                adHold    = -1;
                holdTime += Time.deltaTime;
            }
            else if (Input.GetKey(KeyCode.D))
            {
                if (adHold == -1)
                {
                    adHoldLong = 0;
                    holdTime   = 0;
                }
                adHold    = 1;
                holdTime += Time.deltaTime;
            }
            if ((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D)) ||
                Input.GetAxis("Mouse X") != 0)
            {
                adHold     = 0;
                adHoldLong = 0;
                holdTime   = 0;
            }

            // Code about camera collision
            collision.UpdateCameraClipPoints(transform.position, transform.rotation, ref collision.adjustedCameraClipPoints);
            collision.UpdateCameraClipPoints(desiredPosition, transform.rotation, ref collision.desiredCameraClipPoints);
            collision.CheckColliding(target.transform.position);
            adjustmentDistance = collision.GetAdjustedDistanceWithRayFrom(target.transform.position);

            // Draw debug lines
            for (int i = 0; i < 5; i++)
            {
                if (debug.drawDesiredCollisionLines)
                {
                    Debug.DrawLine(target.position, collision.desiredCameraClipPoints[i], Color.white);
                }
                if (debug.drawAdjustedCollisionLines)
                {
                    Debug.DrawLine(target.position, collision.adjustedCameraClipPoints[i], Color.green);
                }
            }
        }

        if (lockLocation == true)
        {
            transform.parent.Find("Character").transform.position = lockedLocation;
        }
    }