Reputation: 483
I have made a rocket in Unity that goes up and after 5 seconds lands. However, it lands like this:
I have to make it land upside down. How can I make this through code?
My current code as it is:
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;
}
}
}
Upvotes: 1
Views: 1224
Reputation: 24211
Here's the script reference for transform.Rotate of Unity http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html
Try version 3 of Rotate functions. See the given example here:
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);
}
}
Upvotes: 4
Reputation: 16277
Simply change the scale Y from 1 to -1 will do.
gameObject.transform.localScale = new Vector3(1,-1,1);
Upvotes: 2