Beispiel #1
0
    // Update is called once per frame
//	void Update () {
//		if (MyGameManager.delta_angle != 0.0f){
//			float delta_angle = -MyGameManager.delta_angle; //RotSpeed * Time.deltaTime;
//			Debug.Log("CogScript: " + delta_angle);
//			transform.RotateAround (centerPoint.position, Vector3.up, delta_angle);
//
//			/*
//			Debug.Log (transform.position.ToString());
//
//			float curr_angle = transform.rotation.eulerAngles.y;
//			curr_angle += delta_angle;
//			curr_angle = MyTools.ClampAngle (curr_angle);
//			transform.eulerAngles = new Vector3 (0.0f, curr_angle, 0.0f);
//			*/
//			Vector3 cog_local_Angles = Cog_body.transform.localEulerAngles;
//			float cog_curr_angle = cog_local_Angles.z;
//
//			cog_curr_angle += Mathf.Rad2Deg*(Mathf.Deg2Rad*delta_angle*RotMultiplier);
//			cog_curr_angle = MyTools.ClampAngle (cog_curr_angle);
//			cog_local_Angles.z = cog_curr_angle;
//			Cog_body.transform.localEulerAngles = cog_local_Angles;
//			//Cog_body.transform.RotateAround (Cog_body.transform.position, Vector3.forward, cog_curr_angle);
//		}
//
//	}

    public void RotateCog(float delta_angle)
    {
        delta_angle = -delta_angle;
        transform.RotateAround(centerPoint.position, Vector3.up, delta_angle);
        Vector3 cog_local_Angles = Cog_body.transform.localEulerAngles;
        float   cog_curr_angle   = cog_local_Angles.z;

        cog_curr_angle    += Mathf.Rad2Deg * (Mathf.Deg2Rad * delta_angle * RotMultiplier);
        cog_curr_angle     = MyTools.ClampAngle(cog_curr_angle);
        cog_local_Angles.z = cog_curr_angle;
        Cog_body.transform.localEulerAngles = cog_local_Angles;
    }
Beispiel #2
0
    private IEnumerator SmoothStopRoutine()
    {
        float t = 0f;

        while (t < MaxStopTime)
        {
            t += Time.deltaTime;
            float u = SmoothStopCurve.Evaluate(t / MaxStopTime);
            //Debug.Log ("u: " + u);
            float theta     = (Mathf.Rad2Deg * (dx * u / CogBaseRadious)) / RotationSpeed;
            float new_angle = MyTools.ClampAngle(transform.eulerAngles.y - theta * RotationBaseCoef);
            transform.eulerAngles = new Vector3(initRot.x, new_angle, initRot.z);
            RotateCogs(theta);
            yield return(null);
        }
        cogSound.StopOnce();
    }
Beispiel #3
0
 void OnMouseDrag()
 {
     if (bisholding)
     {
         //Debug.Log (RotationSpeed);
         newp = Input.mousePosition;
         dx   = newp.x - oldp.x;
         // convert the distance to angle
         float theta     = (Mathf.Rad2Deg * (dx / CogBaseRadious)) / RotationSpeed;
         float new_angle = MyTools.ClampAngle(transform.eulerAngles.y - theta * RotationBaseCoef);
         //Debug.Log("CogBase: " + theta);
         transform.eulerAngles = new Vector3(initRot.x, new_angle, initRot.z);
         RotateCogs(theta);
         oldp = newp;
     }
     //Debug.Log ("Hold Mouse");
 }