- Home /
need help with roation
hello all iv been making a fps online game and iv made it that you can mount cars helis and tanks and i need help for when i unMount my play spawns in the right rotation cause say my car flips and i want to get out and when i get out my play will be upside down so how can i make my play spawn normal this is my script at the moment if you can help thanks alot
var PlayerPrefab : Transform; var StandByObject : Transform;
function Update () { if(Input.GetKeyUp(KeyCode.E)) { var origin = transform.rotation; Instantiate (PlayerPrefab, transform.position, origin + Vector3( 0, 0, 0)); DestroyNow(); } }
function DestroyNow () { Instantiate(StandByObject, transform.position, transform.rotation); }
Answer by Rennat · Dec 03, 2010 at 04:56 AM
Quick fix is to instantiate the StandByObject
using Quaternion.identity
instead of transform.rotation
so like this var PlayerPrefab : Transform; var StandByObject : Transform;
function Update () { if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.E)) { var origin = transform.position; Instantiate (PlayerPrefab, origin + Vector3( 0, 0, 0), Quaternion.identity(0, 0, 0)); DestroyNow(); } }
function DestroyNow () { Instantiate(StandByObject, transform.position, transform.rotation); }
Answer by josif · Dec 03, 2010 at 05:04 AM
like this ?
var PlayerPrefab : Transform; var StandByObject : Transform;
function Update () { if(Input.GetKeyUp(KeyCode.E)) { var origin = transform.position; Instantiate (PlayerPrefab, origin + Vector3( 0, 0, 0),transform.rotation); DestroyNow(); } }
function DestroyNow () { Instantiate(StandByObject, transform.position, Quaternion.identity); }
please don't use Answers as comments, you should edit your question and add this at the end ins$$anonymous$$d of creating an answer.