コード例 #1
0
ファイル: vp_Shell.cs プロジェクト: ericamccowan/abyssmaze
    ///////////////////////////////////////////////////////////
    // by default a rigidbody will not come to rest in a
    // manner reminiscent of a brass shell, no matter what
    // physics material you have set on it. this method
    // determines if the shell should rest in its upright or
    // tipped over angle, for more realistic shell motion.
    ///////////////////////////////////////////////////////////
    protected void DecideRestAngle()
    {
        float up = Mathf.Abs(transform.eulerAngles.x - 270);		// see how close shell is to its upright position

        // if shell is close to standing up with its (heavier) base
        // toward the ground
        if (up < 55)
        {

            // see if the ground is flat
            Ray ray = new Ray(transform.position, -Vector3.up);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 1))
            {
                // if so, we will force the shell to its upright position
                if (hit.normal == Vector3.up)
                {
                    m_RestAngleFunc = UpRight;
                    rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
                }
            }

            return;

        }

        // either the shell is fairly tilted or the ground is not flat,
        // so we will force the shell to lie down
        m_RestAngleFunc = TippedOver;
    }
コード例 #2
0
ファイル: vp_Shell.cs プロジェクト: GameDevUnity/Networking
    ///////////////////////////////////////////////////////////
    // by default a rigidbody will not come to rest in a
    // manner reminiscent of a brass shell, no matter what
    // physics material you have set on it. this method
    // determines if the shell should rest in its upright or
    // tipped over angle, for more realistic shell motion.
    ///////////////////////////////////////////////////////////
    protected void DecideRestAngle()
    {
        float up = Mathf.Abs(transform.eulerAngles.x - 270);                    // see how close shell is to its upright position

        // if shell is close to standing up with its (heavier) base
        // toward the ground
        if (up < 55)
        {
            // see if the ground is flat
            Ray        ray = new Ray(transform.position, -Vector3.up);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 1))
            {
                // if so, we will force the shell to its upright position
                if (hit.normal == Vector3.up)
                {
                    m_RestAngleFunc       = UpRight;
                    rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
                }
            }

            return;
        }

        // either the shell is fairly tilted or the ground is not flat,
        // so we will force the shell to lie down
        m_RestAngleFunc = TippedOver;
    }
コード例 #3
0
ファイル: vp_Shell.cs プロジェクト: GameDevUnity/Networking
    public List <AudioClip> m_BounceSounds = new List <AudioClip>();    // list of sounds to be randomly played on each ground impact


    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    void Start()
    {
        m_RestAngleFunc = null;

        m_RemoveTime = Time.time + LifeTime;
        m_RestTime   = Time.time + (LifeTime * 0.25f);

        rigidbody.maxAngularVelocity = 100;                     // allow shells to spin faster than rigidbody default

        audio.playOnAwake  = false;
        audio.dopplerLevel = 0.0f;
    }
コード例 #4
0
    void OnEnable()
    {
        m_RestAngleFunc = null;

        m_RemoveTime = Time.time + LifeTime;
        m_RestTime   = Time.time + (LifeTime * 0.25f);

        m_Rigidbody.maxAngularVelocity = 100;                   // allow shells to spin faster than rigidbody default
        m_Rigidbody.velocity           = Vector3.zero;
        m_Rigidbody.angularVelocity    = Vector3.zero;
        m_Rigidbody.constraints        = RigidbodyConstraints.None;

        collider.enabled = true;
    }
コード例 #5
0
	void OnEnable()
	{
	
		m_RestAngleFunc = null;

		m_RemoveTime = Time.time + LifeTime;
		m_RestTime = Time.time + (LifeTime * 0.25f);
		
		m_Rigidbody.maxAngularVelocity = 100;		// allow shells to spin faster than rigidbody default
		m_Rigidbody.velocity = Vector3.zero;
		m_Rigidbody.angularVelocity = Vector3.zero;
		m_Rigidbody.constraints = RigidbodyConstraints.None;
		
		GetComponent<Collider>().enabled = true;
	
	}
コード例 #6
0
    public List <AudioClip> m_BounceSounds = new List <AudioClip>();    // list of sounds to be randomly played on each ground impact


    /// <summary>
    ///
    /// </summary>
    void Start()
    {
        m_Transform = transform;
        m_Rigidbody = GetComponent <Rigidbody>();
        m_Audio     = GetComponent <AudioSource>();

        m_RestAngleFunc = null;

        m_RemoveTime = Time.time + LifeTime;
        m_RestTime   = Time.time + (LifeTime * 0.25f);

        m_Rigidbody.maxAngularVelocity = 100;                   // allow shells to spin faster than rigidbody default

        GetComponent <AudioSource>().playOnAwake  = false;
        GetComponent <AudioSource>().dopplerLevel = 0.0f;
    }
コード例 #7
0
ファイル: vp_Shell.cs プロジェクト: ericamccowan/abyssmaze
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    void Start()
    {
        m_RestAngleFunc = null;

        m_RemoveTime = Time.time + LifeTime;
        m_RestTime = Time.time + (LifeTime * 0.25f);

        rigidbody.maxAngularVelocity = 100;		// allow shells to spin faster than rigidbody default

        audio.playOnAwake = false;
        audio.dopplerLevel = 0.0f;
    }
コード例 #8
0
ファイル: vp_Shell.cs プロジェクト: AndreiMarks/where-are-you
    ///////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////
    void Start()
    {
        m_RestAngleFunc = null;

        m_RemoveTime = Time.time + LifeTime;
        m_RestTime = Time.time + (LifeTime * 0.25f);

        GetComponent<Rigidbody>().maxAngularVelocity = 100;		// allow shells to spin faster than rigidbody default

        GetComponent<AudioSource>().playOnAwake = false;
        GetComponent<AudioSource>().dopplerLevel = 0.0f;
    }