我已经在Unity中制造了一枚火箭,并且在5秒后降落。然而,它是这样的:
我必须让它倒置。我如何通过代码实现这一目标?
我目前的代码是:
double t = 5.0;
void Update () {
GameObject Paraquedas;
GameObject CorpoNariz;
CorpoNariz = GameObject.Find("Corpo_Nariz");
Paraquedas = GameObject.Find("Paraquedas");
rigidbody.AddForce(transform.up * 15);
t -= Time.deltaTime;
if (t <= 0) {
Destroy (CorpoNariz);
Paraquedas.renderer.enabled = true;
transform.Rotate(Time.deltaTime, 0, 0);
rigidbody.AddForce(-transform.up * 50);
rigidbody.drag = 5;
}
}
}
答案 0 :(得分:4)
这是Unity的transform.Rotate的脚本参考 http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html
尝试旋转功能的第3版。请参阅此处给出的示例:
void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour {
void Update() {
transform.Rotate(Vector3.right, Time.deltaTime);
transform.Rotate(Vector3.up, Time.deltaTime, Space.World);
}
}
答案 1 :(得分:2)
只需将比例Y从1更改为-1即可。
gameObject.transform.localScale = new Vector3(1,-1,1);