Exemplo n.º 1
0
    void Update()
    {
        if (playerCore.inputCore.JumpKeyDown && grinding == true)
        {
            grinding = false;

            StartCoroutine(ExitRail());
            playerCore.rb.velocity = currentPath.GetUpTangent(currentRailCompletion, currentPath) * jumpForce;
        }
    }
Exemplo n.º 2
0
    void PathRun()
    {
        //normalize velocity and point it in path dir

        /*
         * playerCore.rb.velocity = Mathf.Clamp(playerCore.velocityMagnitude, leastRunSpeed, 256f)  * currentPath.GetTangent(currentPathCompletion, currentPath);
         * if(raycastToGround == true)
         * {
         *  RaycastHit hit;
         *  if(Physics.Raycast(currentPath.GetPoint(currentPathCompletion, currentPath), -currentPath.GetUpTangent(currentPathCompletion, currentPath), out hit, Mathf.Infinity, (int)PlayerLayerHelper.Layers.Everything, QueryTriggerInteraction.Ignore)){
         *      transform.position = hit.point + hit.normal * playerHeight;
         *  }
         *
         * }
         * else
         * {
         *  transform.position = currentPath.GetPoint(currentPathCompletion, currentPath);
         * }
         */
        if (raycastToGround == true)
        {
            RaycastHit hit;
            if (Physics.Raycast(currentPath.GetPoint(currentPathCompletion, currentPath), -currentPath.GetUpTangent(currentPathCompletion, currentPath), out hit, Mathf.Infinity, (int)PlayerLayerHelper.Layers.Everything, QueryTriggerInteraction.Ignore))
            {
                //transform.position = hit.point + hit.normal * playerHeight;
            }
        }

        //pathRef.forward = currentPath.GetTangent(currentPathCompletion, currentPath);
        pathRef.rotation = Quaternion.LookRotation(currentPath.GetTangent(currentPathCompletion, currentPath), currentPath.GetUpTangent(currentPathCompletion, currentPath));
        Vector3 localVelocity = pathRef.InverseTransformDirection(playerCore.rb.velocity);

        localVelocity.x = 0;// lock local x
        //localVelocity.y = 0;// lock local y

        playerCore.rb.velocity = Vector3.Lerp(playerCore.rb.velocity, pathRef.TransformDirection(localVelocity), tightness);


        if (Vector3.Distance(transform.position, currentPath.GetPoint(currentPathCompletion, currentPath)) > exitDistance)
        {
            StartCoroutine(ExitPath());
        }
    }