Hello all, I have been working on a huge commercial project and have come to a stop where I am not too familiarized in the mathematical side and conditional statements part of programming in C#.
What do I want?
-
My helicopter can travel at speeds and with this speeds I would like a different affect on collision at each speed.
-
My helicopter has been built using Rigidbody, mainly AddForce and AddTorque. I wouldn’t even know how to get the speed value of the Rigidbody.
-
I would like the helicopter to be able to collide with the terrain at different speeds.
I have gone ahead and made some pseudocode to display to show you all what I am trying to achieve. I imagine I have been stuck for over 7 hours now and I guess all the research I have been doing has not lead me to the correct solution.
using UnityEngine;
using System.Collections;
public class CollisionTerrain : MonoBehaviour {
public GameObject terrain;
public ParticleSystem PlayP1;
public ParticleSystem PlayP2;
public ParticleSystem PlayP3;
public GameObject WH;
void OnCollisionEnter(Collision collision) {
if(helicopter.velocity.magnitude > 10); //If Helicopter is faster than a velocity of 10
PlayP1.particleSystem.enableEmission = true; //Helicopter will emit a black smoke and make a damage sound
PlayP1.AudioSource.Play(); // Ignore if wrong
if(helicopter.velocity.magnitude > 25); //If Helicopter is faster than a velocity of 25
PlayP2.particleSystem.enableEmission = true; { Helicopter will emit a deeper black smoke and make a more intense damage sound}
PlayP2.AudioSource.Play(); // Ignore if wrong
if(helicopter.velocity.magnitude > 50); //If Helicopter is faster than a velocity of 25
PlayP3.particleSystem.enableEmission = true; { Helicopter will emit a deeper black smoke and make a more intense damage sound}
PlayP3.AudioSource.Play(); // Ignore if wrong
WH.Instantiate.WreckageObject. //Blown up Helicopter
}
}