void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical   = Input.GetAxis("Vertical");


        if (moveHorizontal == 0 && moveVertical == 0)
        {
            speedCurveTime = 0;
        }
        if (speedCurveTime <= 1)
        {
            speedCurveTime += speedCurveIncrement;
        }


        Vector3 forwardProjection = transform.position + (forwardVector * 2);
        float   hillModifier;

        if (GroundSinControl.CalculateSinPosition(transform.position) > GroundSinControl.CalculateSinPosition(forwardProjection))
        {
            hillModifier = 1.1f;
        }
        else
        {
            hillModifier = 0.85f;
        }

        forwardVector = Quaternion.AngleAxis(moveHorizontal, Vector3.up) * forwardVector;
        movement      = forwardVector * moveVertical;
        float currentSpeed = speed * speedCurve.Evaluate(speedCurveTime);

        jellyMesh.AddForce(movement * currentSpeed * hillModifier, true);        // added hillmodifier to here
        Camera.main.transform.RotateAround(transform.position, Vector3.up, moveHorizontal);
    }
 // Update is called once per frame
 void Update()
 {
     dist = Vector3.Distance(posOri, player.transform.position);
     if (dist < 1.1f && player.transform.position.y - transform.position.y < maxHeight)
     {
         playerMesh.AddForce(new Vector3(0, pushSpeed, 0), false);
     }
 }
Exemple #3
0
    /// <summary>
    /// Update this instance.
    /// </summary>
    void Update()
    {
        m_BounceTimer -= Time.deltaTime;

        // Randomly bounce around
        if (m_BounceTimer < 0.0f)
        {
            Vector3 jumpVector = Vector3.zero;
            jumpVector.x = UnityEngine.Random.Range(m_MinJumpVector.x, m_MaxJumpVector.x);
            jumpVector.y = UnityEngine.Random.Range(m_MinJumpVector.y, m_MaxJumpVector.y);
            jumpVector.z = UnityEngine.Random.Range(m_MinJumpVector.z, m_MaxJumpVector.z);
            jumpVector.Normalize();

            Vector3 torqueVector = Vector3.zero;
            torqueVector.x = UnityEngine.Random.Range(m_MinTorqueVector.x, m_MaxTorqueVector.x);
            torqueVector.y = UnityEngine.Random.Range(m_MinTorqueVector.y, m_MaxTorqueVector.y);
            torqueVector.z = UnityEngine.Random.Range(m_MinTorqueVector.z, m_MaxTorqueVector.z);
            torqueVector.Normalize();

            m_JellyMesh.AddForce(jumpVector * UnityEngine.Random.Range(m_MinJumpForce, m_MaxJumpForce), m_CentralPointOnly);
            m_JellyMesh.AddTorque(torqueVector * UnityEngine.Random.Range(m_MinTorqueForce, m_MaxTorqueForce), false);
            m_BounceTimer = UnityEngine.Random.Range(m_MinBounceTime, m_MaxBounceTime);
        }

        m_EyeTimer            -= Time.deltaTime;
        m_QuaternionLerpTimer += Time.deltaTime;

        if (m_EyeLeft && m_EyeRight)
        {
            if (m_EyeTimer < 0.0f)
            {
                m_EyeTimer            = UnityEngine.Random.Range(2.0f, 3.0f);
                m_QuaternionLerpTimer = 0.0f;

                float randomXAngle = UnityEngine.Random.Range(-45, 45);
                float randomZAngle = UnityEngine.Random.Range(-45, 45);
                m_StartEyeRotation = m_EyeLeft.transform.localRotation;
                m_EndEyeRotation   = m_EyeInitialRotation * Quaternion.Euler(randomXAngle, 0.0f, randomZAngle);
            }

            Quaternion lerpedRotation = Quaternion.Lerp(m_StartEyeRotation, m_EndEyeRotation, Mathf.Clamp01(m_QuaternionLerpTimer * 2));

            m_EyeLeft.transform.localRotation  = lerpedRotation;
            m_EyeRight.transform.localRotation = lerpedRotation;
        }
    }
Exemple #4
0
    private IEnumerator JumpJelly()
    {
        while (true)
        {
            yield return(new WaitForSeconds(jumpWait));

            Vector3 jumpVector = Vector3.up * Random.Range(minJumpPower, maxJumpPower);

            Vector3 torqueVector = Vector3.zero;
            torqueVector.x = Random.Range(-1.0f, 1.0f);
            torqueVector.y = Random.Range(-1.0f, 1.0f);
            torqueVector.z = Random.Range(-1.0f, 1.0f);
            torqueVector.Normalize();
            torqueVector *= Random.Range(minTorquePower, maxTorquePower);

            jelly.AddForce(jumpVector, true);
            jelly.AddTorque(torqueVector, false);

            jumpWait = Random.Range(2.0f, 4.0f);
        }
    }