Duvida Plese Help
3 participantes
Página 1 de 1
Duvida Plese Help
Ola pessoal descupe encomoda mais alguem pode dizer como coloco no meu script ai
Codigo de gasolina e de leva dano quando colidir demais ????
[size=30]@script AddComponentMenu ("CarPhys/Scripts/Car Control Script")[/size]
[size=30]#pragma strict[/size]
[size=30]var centerOfMass : Vector3; //Center of mass[/size]
[size=30]var dataWheel : WheelCollider; //Wheel Collider from which you want to calculate the speed[/size]
[size=30]var lowestSteerAtSpeed : float = 50; //if lowestSteerAtSpeed < currentSpeed the steer Angle = highSpeedSteerAngel[/size]
[size=30]var lowSpeedSteerAngel : float = 10; //This could be a high value[/size]
[size=30]var highSpeedSteerAngel : float = 1; //This shouldn't be a high value (recomended for stability of car)[/size]
[size=30]var decellarationSpeed : float = 30; //How fast the car will decellarate[/size]
[size=30]var maxTorque : float = 50; //Maximum Torque[/size]
[size=30]var currentSpeed : float; //Current Speed of car[/size]
[size=30]var topSpeed : float = 150; //Highest speed at which the car can go[/size]
[size=30]var maxReverseSpeed : float = 50; //Highest Reverse speed[/size]
[size=30]var backLightObject : GameObject; //Mesh for reverse light[/size]
[size=30]var idleLightMaterial : Material; //for idle state[/size]
[size=30]var brakeLightMaterial : Material; //Braked state[/size]
[size=30]var reverseLightMaterial : Material; //Reverse state[/size]
[size=30]@HideInInspector [/size]
[size=30]var braked : boolean = false; //Brake trigger[/size]
[size=30]var maxBrakeTorque : float = 100; //Braking speed[/size]
[size=30]var speedOMeterDial : Texture2D; //GUI Texture for dial[/size]
[size=30]var speedOMeterPointer : Texture2D; //GUI Texture for needle[/size]
[size=30]var gearRatio : int[]; //Shift gear at speed[/size]
[size=30]//var spark : GameObject; //OnCollision Spark[/size]
[size=30]var collisionSound : GameObject; //OnCollision Sound[/size]
[size=30]var minAnglePointer : int = -90;[/size]
[size=30]var maxAnglePointer : int = 180;[/size]
[size=30]function Start () {[/size]
[size=30]rigidbody.centerOfMass=centerOfMass; //Center of mass , for this the car should be pointing on z axis[/size]
[size=30]}[/size]
[size=30]function FixedUpdate () {[/size]
[size=30]HandBrake();[/size]
[size=30]}[/size]
[size=30]function Update(){[/size]
[size=30]BackLight ();[/size]
[size=30]EngineSound();[/size]
[size=30]CalculateSpeed();[/size]
[size=30]}[/size]
[size=30]//Speed Calculation[/size]
[size=30]function CalculateSpeed(){[/size]
[size=30]currentSpeed = 2*22/7*dataWheel.radius*dataWheel.rpm*60/1000;[/size]
[size=30]currentSpeed = Mathf.Round(currentSpeed);[/size]
[size=30]}[/size]
[size=30]//Light Control[/size]
[size=30]function BackLight (){[/size]
[size=30]if (currentSpeed > 0 && Input.GetAxis("Vertical")<0&&!braked){[/size]
[size=30]backLightObject.renderer.material = brakeLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (currentSpeed < 0 && Input.GetAxis("Vertical")>0&&!braked){[/size]
[size=30]backLightObject.renderer.material = brakeLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (currentSpeed < 0 && Input.GetAxis("Vertical")<0&&!braked){[/size]
[size=30]backLightObject.renderer.material = reverseLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (!braked){[/size]
[size=30]backLightObject.renderer.material = idleLightMaterial;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]//Brake Trigger[/size]
[size=30]function HandBrake(){[/size]
[size=30]if (Input.GetButton("Jump")){[/size]
[size=30]braked = true;[/size]
[size=30]}[/size]
[size=30]else{[/size]
[size=30]braked = false;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]//Engine Sound[/size]
[size=30]function EngineSound(){[/size]
[size=30]for (var i = 0; i < gearRatio.length; i++){[/size]
[size=30]if(gearRatio[i]> currentSpeed){[/size]
[size=30]break;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]var gearMinValue : float = 0.00;[/size]
[size=30]var gearMaxValue : float = 0.00;[/size]
[size=30]if (i == 0){[/size]
[size=30]gearMinValue = 0;[/size]
[size=30]}[/size]
[size=30]else {[/size]
[size=30]gearMinValue = gearRatio[i-1];[/size]
[size=30]}[/size]
[size=30]gearMaxValue = gearRatio[i];[/size]
[size=30]var enginePitch : float = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue))+1;[/size]
[size=30]audio.pitch = enginePitch;[/size]
[size=30]}[/size]
[size=30]//Speedometer[/size]
[size=30]function OnGUI (){[/size]
[size=30]GUI.DrawTexture(Rect(Screen.width - 300,Screen.height - 300,300,300),speedOMeterDial);[/size]
[size=30]var speedFactor : float = currentSpeed / topSpeed;[/size]
[size=30]var rotationAngle : float;[/size]
[size=30]if (currentSpeed >= 0){[/size]
[size=30] rotationAngle = Mathf.Lerp(minAnglePointer,maxAnglePointer,speedFactor);[/size]
[size=30] }[/size]
[size=30] else {[/size]
[size=30] rotationAngle = Mathf.Lerp(minAnglePointer,maxAnglePointer,-speedFactor);[/size]
[size=30] }[/size]
[size=30]GUIUtility.RotateAroundPivot(rotationAngle,Vector2(Screen.width - 150 ,Screen.height - 150));[/size]
[size=30]GUI.DrawTexture(Rect(Screen.width - 300,Screen.height - 300,300,300),speedOMeterPointer);[/size]
[size=30]}[/size]
[size=30]//CollisioN FX[/size]
[size=30]function OnCollisionEnter (other : Collision){[/size]
[size=30]if (other.transform != transform && other.contacts.length != 0){[/size]
[size=30]for (var i = 0; i < other.contacts.length ; i++){[/size]
[size=30]//Instantiate(spark,other.contacts[i].point,Quaternion.identity);[/size]
[size=30]var clone : GameObject = Instantiate(collisionSound,other.contacts[i].point,Quaternion.identity);[/size]
[size=30]clone.transform.parent = transform;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]function OnDrawGizmos () {[/size]
[size=30] Gizmos.color = Color.white;[/size]
[size=30] Gizmos.DrawWireSphere (transform.position+centerOfMass, 0.1);[/size]
[size=30] }[/size]
Codigo de gasolina e de leva dano quando colidir demais ????
[size=30]@script AddComponentMenu ("CarPhys/Scripts/Car Control Script")[/size]
[size=30]#pragma strict[/size]
[size=30]var centerOfMass : Vector3; //Center of mass[/size]
[size=30]var dataWheel : WheelCollider; //Wheel Collider from which you want to calculate the speed[/size]
[size=30]var lowestSteerAtSpeed : float = 50; //if lowestSteerAtSpeed < currentSpeed the steer Angle = highSpeedSteerAngel[/size]
[size=30]var lowSpeedSteerAngel : float = 10; //This could be a high value[/size]
[size=30]var highSpeedSteerAngel : float = 1; //This shouldn't be a high value (recomended for stability of car)[/size]
[size=30]var decellarationSpeed : float = 30; //How fast the car will decellarate[/size]
[size=30]var maxTorque : float = 50; //Maximum Torque[/size]
[size=30]var currentSpeed : float; //Current Speed of car[/size]
[size=30]var topSpeed : float = 150; //Highest speed at which the car can go[/size]
[size=30]var maxReverseSpeed : float = 50; //Highest Reverse speed[/size]
[size=30]var backLightObject : GameObject; //Mesh for reverse light[/size]
[size=30]var idleLightMaterial : Material; //for idle state[/size]
[size=30]var brakeLightMaterial : Material; //Braked state[/size]
[size=30]var reverseLightMaterial : Material; //Reverse state[/size]
[size=30]@HideInInspector [/size]
[size=30]var braked : boolean = false; //Brake trigger[/size]
[size=30]var maxBrakeTorque : float = 100; //Braking speed[/size]
[size=30]var speedOMeterDial : Texture2D; //GUI Texture for dial[/size]
[size=30]var speedOMeterPointer : Texture2D; //GUI Texture for needle[/size]
[size=30]var gearRatio : int[]; //Shift gear at speed[/size]
[size=30]//var spark : GameObject; //OnCollision Spark[/size]
[size=30]var collisionSound : GameObject; //OnCollision Sound[/size]
[size=30]var minAnglePointer : int = -90;[/size]
[size=30]var maxAnglePointer : int = 180;[/size]
[size=30]function Start () {[/size]
[size=30]rigidbody.centerOfMass=centerOfMass; //Center of mass , for this the car should be pointing on z axis[/size]
[size=30]}[/size]
[size=30]function FixedUpdate () {[/size]
[size=30]HandBrake();[/size]
[size=30]}[/size]
[size=30]function Update(){[/size]
[size=30]BackLight ();[/size]
[size=30]EngineSound();[/size]
[size=30]CalculateSpeed();[/size]
[size=30]}[/size]
[size=30]//Speed Calculation[/size]
[size=30]function CalculateSpeed(){[/size]
[size=30]currentSpeed = 2*22/7*dataWheel.radius*dataWheel.rpm*60/1000;[/size]
[size=30]currentSpeed = Mathf.Round(currentSpeed);[/size]
[size=30]}[/size]
[size=30]//Light Control[/size]
[size=30]function BackLight (){[/size]
[size=30]if (currentSpeed > 0 && Input.GetAxis("Vertical")<0&&!braked){[/size]
[size=30]backLightObject.renderer.material = brakeLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (currentSpeed < 0 && Input.GetAxis("Vertical")>0&&!braked){[/size]
[size=30]backLightObject.renderer.material = brakeLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (currentSpeed < 0 && Input.GetAxis("Vertical")<0&&!braked){[/size]
[size=30]backLightObject.renderer.material = reverseLightMaterial;[/size]
[size=30]}[/size]
[size=30]else if (!braked){[/size]
[size=30]backLightObject.renderer.material = idleLightMaterial;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]//Brake Trigger[/size]
[size=30]function HandBrake(){[/size]
[size=30]if (Input.GetButton("Jump")){[/size]
[size=30]braked = true;[/size]
[size=30]}[/size]
[size=30]else{[/size]
[size=30]braked = false;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]//Engine Sound[/size]
[size=30]function EngineSound(){[/size]
[size=30]for (var i = 0; i < gearRatio.length; i++){[/size]
[size=30]if(gearRatio[i]> currentSpeed){[/size]
[size=30]break;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]var gearMinValue : float = 0.00;[/size]
[size=30]var gearMaxValue : float = 0.00;[/size]
[size=30]if (i == 0){[/size]
[size=30]gearMinValue = 0;[/size]
[size=30]}[/size]
[size=30]else {[/size]
[size=30]gearMinValue = gearRatio[i-1];[/size]
[size=30]}[/size]
[size=30]gearMaxValue = gearRatio[i];[/size]
[size=30]var enginePitch : float = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue))+1;[/size]
[size=30]audio.pitch = enginePitch;[/size]
[size=30]}[/size]
[size=30]//Speedometer[/size]
[size=30]function OnGUI (){[/size]
[size=30]GUI.DrawTexture(Rect(Screen.width - 300,Screen.height - 300,300,300),speedOMeterDial);[/size]
[size=30]var speedFactor : float = currentSpeed / topSpeed;[/size]
[size=30]var rotationAngle : float;[/size]
[size=30]if (currentSpeed >= 0){[/size]
[size=30] rotationAngle = Mathf.Lerp(minAnglePointer,maxAnglePointer,speedFactor);[/size]
[size=30] }[/size]
[size=30] else {[/size]
[size=30] rotationAngle = Mathf.Lerp(minAnglePointer,maxAnglePointer,-speedFactor);[/size]
[size=30] }[/size]
[size=30]GUIUtility.RotateAroundPivot(rotationAngle,Vector2(Screen.width - 150 ,Screen.height - 150));[/size]
[size=30]GUI.DrawTexture(Rect(Screen.width - 300,Screen.height - 300,300,300),speedOMeterPointer);[/size]
[size=30]}[/size]
[size=30]//CollisioN FX[/size]
[size=30]function OnCollisionEnter (other : Collision){[/size]
[size=30]if (other.transform != transform && other.contacts.length != 0){[/size]
[size=30]for (var i = 0; i < other.contacts.length ; i++){[/size]
[size=30]//Instantiate(spark,other.contacts[i].point,Quaternion.identity);[/size]
[size=30]var clone : GameObject = Instantiate(collisionSound,other.contacts[i].point,Quaternion.identity);[/size]
[size=30]clone.transform.parent = transform;[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]}[/size]
[size=30]function OnDrawGizmos () {[/size]
[size=30] Gizmos.color = Color.white;[/size]
[size=30] Gizmos.DrawWireSphere (transform.position+centerOfMass, 0.1);[/size]
[size=30] }[/size]
mateus202- Iniciante
- PONTOS : 3116
REPUTAÇÃO : 0
Respeito as regras :
Re: Duvida Plese Help
Vc tem que criar um javascript na aba project, clique com o botão direito do mouse>new>javascript... ai vc abre, provavelmente vai abrir o monodevelop ai vc copia e cola seu script la.
Re: Duvida Plese Help
Java cara, por que java? Por que trabalha com java? Tem tutorial sobre dano e tudo mais no canal, mas na linguagem top padrão, que é C#
Tópicos semelhantes
» [Duvida] Duvida Com script de mover em direção ao mouse.
» [DÚVIDA] Dúvida sobre script e rigidbody
» UMA DUVIDA DO C#❓❓❓
» Duvida
» [DUVIDA] ADS Em app WPF.NET ?
» [DÚVIDA] Dúvida sobre script e rigidbody
» UMA DUVIDA DO C#❓❓❓
» Duvida
» [DUVIDA] ADS Em app WPF.NET ?
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos