Domanda

I have made a rocket in Unity that goes up and after 5 seconds lands. However, it lands like this:

Rocket.

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;
        }
    }
}
È stato utile?

Soluzione

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);
    }
}

Altri suggerimenti

Simply change the scale Y from 1 to -1 will do.

gameObject.transform.localScale = new Vector3(1,-1,1);

enter image description here

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top