예제 #1
0
    /// <summary>
    /// Makes the player jump plus or less high depending on the time the key is pressed
    /// </summary>
    /// <param name="_key">Jump's key</param>
    /// <returns></returns>
    private IEnumerator JumpCoroutine(KeyCode _key)
    {
        TDS_CustomDebug.CustomDebugLog("Start Jump !");

        // Timer used for the maximum jump time length
        float _timer = 0;

        // Adds the initial jump force to the rigidbody
        rigidbody.AddForce(Vector3.up * JumpForce);

        // While the jump key is hold and the jump is not at its maximum time length, go higher
        while (Input.GetKey(_key) && (_timer < JumpMaxTime))
        {
            // Increases the rigidbody velocity
            rigidbody.AddForce(Vector3.up * JumpForceIncrease);

            // Wait for the next frame
            yield return(new WaitForEndOfFrame());

            // Increases the timer
            _timer += Time.deltaTime;
        }

        TDS_CustomDebug.CustomDebugLog("End Jump...");
    }
예제 #2
0
 private void Awake()
 {
     // Set the instance if needed
     if (!Instance)
     {
         Instance = this;
     }
     else
     {
         TDS_CustomDebug.CustomDebugLog("There is already a camera instance in this scene ! Destroys CameraBehaviour script", "Lucas");
         Destroy(this);
         return;
     }
 }
예제 #3
0
    protected virtual void DestroyThrowable()
    {
        TDS_CustomDebug.CustomDebugLog($"Destroy throwable => {name}");

        Destroy(gameObject);
    }