2015-04-24 70 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

回答