2015-04-24 102 views
0


我創造了跟隨玩家的敵人並旋轉。我的問題是,我的飛船模型旋轉是不同的,當我用Blender做它。
這是敵人如何遵守,如何船看起來像旋轉X:0 Y:0 Z:0
http://i.stack.imgur.com/bLbaz.png
在攪拌機,一切都很好,沒有錯,旋轉等
這是敵人腳本
敵人關注玩家,輪轉

using UnityEngine; 
using System.Collections; 

public class Enemy : MonoBehaviour { 

     public static float health; 
     private float reloadTime; 

     public Rigidbody laser; 
     public GameObject explo; 
     public Transform playerShip; 

     // Use this for initialization 
     void Start() { 
       health = 20.0f; 
       reloadTime = 0.3f; 
     } 

     // Update is called once per frame 
     void Update() { 

       //transform.LookAt(playerShip.transform.position); 
       Quaternion rotation = Quaternion.LookRotation(playerShip.transform.position - this.transform.position); 
       transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2); 
       transform.Translate(Vector3.forward * 2 * Time.deltaTime); 

       reloadTime -= Time.deltaTime; 

       if(reloadTime <= 0f) 
       { 
         Rigidbody clone = Instantiate(laser, transform.position, transform.rotation) as Rigidbody; 
         clone.velocity = transform.TransformDirection(0, 0, 80); 
         Destroy(clone.gameObject, 3); 
         reloadTime = 0.3f; 
       } 

       if(health <= 0f) 
       { 
         GameObject exp = Instantiate(explo, transform.position, transform.rotation) as GameObject; 
         Destroy(this.gameObject); 
         Destroy(exp.gameObject, 1.5f); 
       } 
     } 
} 

這種旋轉會出現什麼問題?

如何更改此代碼中的旋轉因此X總是270?

  Quaternion rotation = Quaternion.LookRotation(playerShip.transform.position - this.transform.position); 
      transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2); 
+0

在這裏發佈您的代碼,而不是第三方網站。 – Dom

+0

不僅如此,發佈*具體*不起作用。 「這種旋轉有什麼問題?」根本不能說明你的具體問題是什麼。 –

+0

我在問這個奇怪的模型位置。爲什麼它不像它應該(在圖像上,右邊的船很好,但X旋轉= 270)。 – Oen44

回答