- Home /
Vehicle exit rotation bug / random vehicle explosions bug.
hello, im having problems with player rotations and random vehicle explisons #pragma strict import UnityStandardAssets.CrossPlatformInput;
var masinoj = false;
var peskom = true;
var triggeris = false;
var zaidejas : Transform;
var masina : GameObject;
var taskas : Transform;
var crashas : AudioSource;
var smarkei : AudioClip[];
var silpnai : AudioClip[];
var Ugnys : GameObject[];
var Dumai : GameObject;
var Sprogimas : GameObject;
var Sudegesmasina : GameObject;
var Damage : int;
function Update() {
if(Damage < 11){
for(var i = 0;i<Ugnys.Length;i++){
Ugnys[i].SetActive(true);
}
}
if(Damage < 31){
Dumai.SetActive(true);
}
if(Damage < 1){
masinoj = false;
zaidejas.transform.rotation = Quaternion(0,0,0,0);
Sprogimas.SetActive(true);
Instantiate(Sudegesmasina, transform.position, transform.rotation);
zaidejas.transform.rotation = Quaternion(0,0,0,0);
zaidejas.transform.localRotation = Quaternion(0,0,0,0);
Destroy(gameObject);
}
if(triggeris){
if (CrossPlatformInputManager.GetButtonDown("Enter"))
masinoj = !masinoj;
}
if(triggeris == false){
masinoj = false;
}
if(masinoj){
zaidejas.gameObject.SetActive (false);
zaidejas.parent = taskas.transform;
zaidejas.transform.localPosition = Vector3(-0.25,0.25,0);
zaidejas.transform.localRotation = Quaternion(0,0,0,0);
taskas.parent = masina.transform;
taskas.transform.localPosition = Vector3(-0.25,0.25,0);
(masina.GetComponent("CarUserControl") as UnityStandardAssets.Vehicles.Car.CarUserControl).enabled = true;
}
else{
zaidejas.gameObject.SetActive (true);
zaidejas.transform.parent = null;
(masina.GetComponent("CarUserControl") as UnityStandardAssets.Vehicles.Car.CarUserControl).enabled = false;
}
}
function OnCollisionEnter(collision: Collision) {
if (collision.relativeVelocity.magnitude < 14 && collision.relativeVelocity.magnitude > 10){
Damage = Damage-5;
crashas.Stop();
crashas.PlayOneShot(silpnai[Random.Range(0,silpnai.Length)]);
}
else if (collision.relativeVelocity.magnitude > 15){
Damage = Damage-10;
crashas.Stop();
crashas.PlayOneShot(smarkei[Random.Range(0,smarkei.Length)]);
}
}
function OnTriggerEnter(collider : Collider){
if(collider.tag == "Player")
{
triggeris = true;
}
}
function OnTriggerExit(collider : Collider){
if(collider.tag == "Player")
{
triggeris = false;
}
}
Masinoj means inside car
peskom means on foot
triggeris trigger
zaidejas - player
Masina - car
ttaskas - exit point
crashas - crash sound audio source
smarkei - heavy crash array of sounds
silpnai - light crash array of sounds
ugnys - array of fire effects
dumai - smoke
sprogimas - explision effect
sudegesmasina - broken car burnt prefab
damage - damage points
images to be clearer
^ exploding
^ bad player rotation
So i need help to what to do to get player standing on foot when he exits the vehicles , and whats the thing that some cars upon enter does explode and play crash sounds very much randomly. Thanks for help
Your answer
Follow this Question
Related Questions
Objects Rotation to modify Objects transform velocity/Direction of travel 1 Answer
How do you make a player move on a remote items local axis? 0 Answers
MP - Enter & Exit Any Vehicle 2 Answers
How to make a steering wheel that rotates when wheels do? 0 Answers
How to make a player rotate in a direction with a slope of the ground. 0 Answers