예제 #1
0
 void UpdateTargetCenterOfMass()
 {
     if (TargetCenterOfMass == null)
     {
         TargetCenterOfMass = FindObjectOfType <ComplexMassController>();
     }
 }
    public bool CanJump()
    {
        Vector3 down = ComplexMassController.GetRotatorForLocation(transform.position) * Vector3.down;
        var     hit  = Physics2D.Raycast(transform.position, down, StandingHeight, LayerMask.GetMask("Moon", "Asteroid"));

        return(hit);
    }
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.yellow;

        Vector3 down = ComplexMassController.GetRotatorForLocation(transform.position) * Vector3.down;

        Gizmos.DrawRay(transform.position, down * StandingHeight);
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        transform.rotation = ComplexMassController.GetRotatorForLocation(transform.position);

        float InputProjectionOnVelocity = Vector3.Dot(_accumulatedForce.normalized, _rigidbody2D.velocity);

        if (InputProjectionOnVelocity < MaxInputVelocity)
        {
            _rigidbody2D.AddRelativeForce(_accumulatedForce * Time.deltaTime, ForceMode2D.Force);
        }

        _rigidbody2D.AddForce(_accumulatedWorldForce * Time.deltaTime, ForceMode2D.Force);

        _rigidbody2D.AddRelativeForce(_accumulatedImpulse, ForceMode2D.Impulse);

        _accumulatedForce      = new Vector3();
        _accumulatedWorldForce = new Vector3();
        _accumulatedImpulse    = new Vector3();
    }
 private void Awake()
 {
     WorldComplexMassController = this;
 }