Пример #1
0
    public void KickFromHuman(Vector3 v3PropDirection)
    {
        // Enable the player's meshes.
        m_meshRoot.SetActive(true);

        // Enable look pointer.
        m_pointer.SetActive(true);

        // Stun player.
        Stun();

        // Disable collision between this player and the human.
        Physics.IgnoreCollision(m_controller, m_humanController, true);

        // Throw player:
        // Ensure ghost position is equal to the human's position.
        transform.parent   = null;
        transform.position = m_human.transform.position;

        // Enable movement.
        m_movement.enabled   = true;
        m_controller.enabled = true;

        v3PropDirection.y = 0.0f;

        // Add direction vector to up force, normalize and multiply by stun force and add the force.
        m_movement.ResetVelocity(); // Ensure any previous velocity of the ghost doesn't remain.
        m_movement.AddForce(v3PropDirection * m_fStunForce);
        m_movement.AddForce(Vector3.up * m_fStunForce);

        // Mark human as not possessed.
        m_humanScript.SetPossessed(false);

        m_possessedObj = null;
    }
Пример #2
0
    private void FinalJump()
    {
        if (recovering)
        {
            Camera  cam   = Camera.main;
            Vector2 mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            float angle = Utils.AngleFromTwoPoints(weapon_pivot.transform.position, mouse);

            Vector2 dir_vec = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
            dir_vec.Normalize();

            pm.EnableGravity();
            pm.AddForce(dir_vec, 2000);

            recover_waiting_finish = false;
            recovering             = false;

            weapon_head.transform.localPosition = head_starting_shoot_pos;

            weapon_head_renderer.sprite = closed_head_sprite;

            DestroyTrails();
        }
    }
Пример #3
0
    private IEnumerator Jump_Coroutine()
    {
        _animator.SetBool("Jump", true);
        _playerMovement.AddForce(Direction, ForceAmmount);
        yield return(new WaitForSeconds(0.1f));

        _animator.SetBool("Jump", false);
    }
Пример #4
0
 // Create explosion, adding explosion force to object within max range
 private void Explode(Collider otherCollider)
 {
     // Get nearby objects
     _nearbyObjects = Physics.OverlapSphere(transform.position,
                                            MAX_RADIUS);
     foreach (Collider nearbyObj in _nearbyObjects)
     {
         PlayerMovement plyrMov =
             nearbyObj.GetComponent <PlayerMovement>();
         if (plyrMov != null)
         {
             // Apply force
             Vector3 dir = transform.position -
                           plyrMov.transform.position;
             Vector3 _explosionForce = dir.normalized *
                                       MAX_EXPLOSION_FORCE_MODIFIER;
             plyrMov.AddForce(-_explosionForce);
         }
     }
     // Remove mine
     Destroy(gameObject);
 }
Пример #5
0
 public void AddForce(Vector2 force)
 {
     movement.AddForce(force);
 }