Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

gonzalitosk8

Newbie
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

About gonzalitosk8

  • Rank
    Newbie
  1. if you used a 3d menu, create separated scripts: C#: using UnityEngine; using System.Collections; public class Simple : MonoBehaviour { void OnMouseDown(){ QualitySettings.currentLevel = QualityLevel.Simple; } } if you click the box, the quality is changed to "simple" remember assign one collider to box object, and click "is trigger" in collider options. I reccomend use 3d menu, its more beatiful, and more easy!
  2. Hi! I have a question to apply a "stop" to this script .. to tighten ("shiftUp" button) I want the audio stops for a while (in this case the value of ShiftTime) if time is greater than 0, the audio stops .. if time is less than or equal to 0, the audio plays another look... Here I give you the script in c # : using UnityEngine; using System.Collections; public class prueba : MonoBehaviour { public AudioClip test; public float testvolumenMax = 1; public float testpitch = 1; public float ShiftTime = 0.8f; AudioSource testSource; Drivetrain drivetrain; float volumeFactor; int i,k; AudioSource CreateAudioSource(AudioClip clip, bool loop, bool playImmediately, Vector3 position) { GameObject go = new GameObject("audio"); go.transform.parent = transform; go.transform.localPosition = position; go.transform.localRotation = Quaternion.identity; go.AddComponent(typeof(AudioSource)); go.audio.clip = clip; go.audio.playOnAwake = false; if (loop==true){ go.audio.volume = 0; go.audio.loop = true; } else go.audio.loop = false; if (playImmediately) go.audio.Play(); return go.audio; } void Start () { drivetrain=GetComponent<Drivetrain>(); testSource = CreateAudioSource(test, true, true,Vector3.zero); } void Update () { if(Input.GetButton ("Throttle")){ if(this.drivetrain.rpm>100){ {if (!testSource.isPlaying) testSource.Play();} float factor=drivetrain.rpm/drivetrain.maxRPM; testSource.volume = 0 + testvolumenMax*factor; testSource.pitch = 0.1f + testpitch*factor +0.3f; } } else { float factor=drivetrain.rpm/drivetrain.maxRPM; testSource.volume = 0.1f + testvolumenMax*factor-0.1f; testSource.pitch = 0.1f + testpitch*factor -0.15f; } } } ------------------ how I can apply a stop time to audio? help me? Thanks!
  3. it's not what I want, the factor is created between minrpm audio.pitch / maxrpm .. what I want is the solution to create a fadevolume between factors as explain. no reply! well thanks bro!
  4. Hello everyone! I have a dilemma that I can not solve. I comment as it comes. want to create a sound engine, with different bases on engine rpm. I will explain my idea! Script: using UnityEngine; using System.Collections; public class RealSonidoMotor : MonoBehaviour { public audioClip Low; public float fadeOutL = 3000; //(these are the rpm) public float EndfadeOutL = 7000; public audioClip Med; public float startM = 3000;//(volume starts from 0) public float fadeInM = 4000;//(Volume 0-1) public float fadeOutM = 6000;//(Volume 1-0) public float EndfadeOutM = 7000;//(volume 0) public audioClip High; public float startH = 5000; public float fadeInH = 7000; Drivetrain drivetrain; float volumeFactor; int i,k; AudioSource CreateAudioSource(AudioClip clip, bool loop, bool playImmediately, Vector3 position) { GameObject go = new GameObject("audio"); go.transform.parent = transform; go.transform.localPosition = position; go.transform.localRotation = Quaternion.identity; go.AddComponent(typeof(AudioSource)); go.audio.clip = clip; go.audio.playOnAwake = false; if (loop==true){ go.audio.volume = 0; go.audio.loop = true; } else go.audio.loop = false; if (playImmediately) go.audio.Play(); return go.audio; } void Start () { LowSource = CreateAudioSource(Low, true, true,Vector3.zero); MedSource = CreateAudioSource(Med, true, true,Vector3.zero); HighSource = CreateAudioSource(High, true, true,Vector3.zero); drivetrain=GetComponent<Drivetrain>(); } void Update () { if(drivetrain.throttle > 0){ if(Input.GetButton ("Throttle")){ if(this.drivetrain.rpm > 800){ {if (!LowSource.isPlaying) LowSource.Play();} LowSource.volume=1; } if(this.drivetrain.rpm > fadeOutL){ LowSource.volume = the problem is here, I want the volume down to 1-0 between floats "fadeOutL / EndfadeOutL" } } } } } ----------------------------------------------------------------------------------------- the vehicle has different gears: 1,2,3,4,5 and 6 making the next "gear" rpm slower increase as it does in reality .. any idea?
  5. search the internet, but only find results like this: enable / disable script from js .. if I had found it, I would not ask .. know it? I explain it?
  6. how to enable and disable scripts with another script? (c#) script: using UnityEngine; using System.Collections; public class nitro : MonoBehaviour { public Component N20; public Component Setup; void Start(){ N20 = GetComponent<N20>(); Setup = GetComponent<Setup>(); } void Update(){ if(Input.GetButtonDown("nitro")){ N20.enable = true; Setup.enable = false; } else { if(Input.GetButtonUp("nitro")){ N20.enable = false; Setup.enable = true; } } } } Message error on unity: nitro.cs(16,9): error CS1061: Type `UnityEngine.Component' does not contain a definition for `enable' and no extension method `enable' of type `UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?) help me please!
  7. hello all .. some time ago, I needed someone to help me and only one person concentrated on helping .. the idea of ​​the script, was to create a professional sound engine, with 4 beeps .. (Idle, low, med, high) and to see that the rpm will increase, the sounds are activated and disabling above .. eg == 1000 -> 1000 = low = play sound == 3000 -> 3000 = med = play sound and stop low etc. .. I think the idea .. but not how to do it properly, and not that long ago I started with this .. script (CS) = using UnityEngine; public class SoundEngine : MonoBehaviour { bool debug=false; public AudioClip Idle; public float IdleVolume=0.35f; public float IdlePitchFactor=1f; public AudioClip engineLow; public float engineLowVolume=0.35f; public float engineLowPitchFactor=1f; public AudioClip engineMed; public float engineMedVolume=0.35f; public float engineMedPitchFactor=1f; public AudioClip engineMax; public float engineMaxVolume=0.35f; public float engineMaxPitchFactor=1f; public AudioClip engineNoLow; public float engineNoLowVolume=0.35f; public float engineNoLowPitchFactor=1f; public AudioClip engineNoMed; public float engineNoMedVolume=0.35f; public float engineNoTMedPitchFactor=1f; public AudioClip engineNoHigh; public float engineNoHighVolume=0.35f; public float engineNoHighPitchFactor=1f; AudioSource IdleSource; AudioSource engineLowSource; AudioSource engineMedSource; AudioSource engineHighSource; AudioSource engineNoLowSource; AudioSource engineNoMedSource; AudioSource engineNoHighSource; private Drivetrain drivetrain; float volumeFactor; int i,k; public void SetDebug(bool db){ debug=db; } AudioSource CreateAudioSource (AudioClip clip, bool loop, bool playImmediately, Vector3 position) { GameObject go = new GameObject("audio"); go.transform.parent = transform; go.transform.localPosition = position; go.transform.localRotation = Quaternion.identity; go.AddComponent(typeof(AudioSource)); go.audio.clip = clip; go.audio.playOnAwake = false; if (loop==true){ go.audio.volume = 0; go.audio.loop = true; } else go.audio.loop = false; if (playImmediately) go.audio.Play(); return go.audio; } public void EngineLow() { if ((this.drivetrain.rpm == 1000f) || (this.drivetrain.rpm > 1000f)) { this.EngineLowSource.audioSource = AudioSource.EngineLow; this.EngineLowSource.audioSource = this.EngineLow; Vector3 enginePositionV=Vector3.zero; engineLowSource = CreateAudioSource(engineLow, true, true,enginePositionV); } else { this.EngineNoLowSource.audioSource = AudioSource.EngineNoLow; this.EngineNoLowSource.audioSource = this.EngineNoLow; Vector3 enginePositionV=Vector3.zero; engineNoLowSource = CreateAudioSource(engineNoLow, true, true,enginePositionV); } if (this.drivetrain.rpm > 2000f) { this.EngineLowSource.audioSource = AudioSource.EngineLow; this.EngineLowSource.audioSource = this.EngineLow; } else { this.EngineNoLowSource.audioSource = AudioSource.EngineNoLow; this.EngineNoLowSource.audioSource = this.EngineNoLow; } if (this.drivetrain.rpm > 3000f) { this.EngineLowSource.audioSource = AudioSource.EngineLow; this.EngineLowSource.audioSource = this.EngineLow; this.EngineMedSource.audioSource = AudioSource.EngineMed; this.EngineMedSource.audioSource = this.EngineMed; Vector3 enginePositionV=Vector3.zero; engineMedSource = CreateAudioSource(engineMed, true, true,enginePositionV); } else { this.EngineNoLowSource.audioSource = AudioSource.EngineNoLow; this.EngineNoLowSource.audioSource = this.EngineNoLow; this.EngineNoMedSource.audioSource = AudioSource.EngineNoMed; this.EngineNoMedSource.audioSource = this.EngineNoMed; Vector3 enginePositionV=Vector3.zero; engineNoMedSource = CreateAudioSource(engineNoMed, true, true,enginePositionV); } if (this.drivetrain.rpm > 4000f) { this.EngineMedSource.audioSource = AudioSource.EngineMed; this.EngineMedSource.audioSource = this.EngineMed; } else { this.EngineNoMedSource.audioSource = AudioSource.EngineNoMed; this.EngineNoMedSource.audioSource = this.EngineNoMed; } if (this.drivetrain.rpm > 6000f) { this.EngineMedSource.audioSource = AudioSource.EngineMed; this.EngineMedSource.audioSource = this.EngineMed; } else { this.EngineNoMedSource.audioSource = AudioSource.EngineNoMed; this.EngineNoMedSource.audioSource = this.EngineNoMed; } if (this.drivetrain.rpm > 7000f) { this.EngineMedSource.audioSource = AudioSource.EngineMed; this.EngineMedSource.audioSource = this.EngineMed; this.EngineHighSource.audioSource = AudioSource.EngineHigh; this.EngineHighSource.audioSource = this.EngineHigh; Vector3 enginePositionV=Vector3.zero; engineMedSource = CreateAudioSource(engineMed, true, true,enginePositionV); } else { this.EngineNoMedSource.audioSource = AudioSource.EngineNoMed; this.EngineNoMedSource.audioSource = this.EngineNoMed; this.EngineNoHighSource.audioSource = AudioSource.EngineNoHigh; this.EngineNoHighSource.audioSource = this.EngineNoHigh; Vector3 enginePositionV=Vector3.zero; engineNoMedSource = CreateAudioSource(engineNoMed, true, true,enginePositionV); } if (this.drivetrain.rpm > 8000f) { this.EngineHighSource.audioSource = AudioSource.EngineHigh; this.EngineHighSource.audioSource = this.EngineHigh; } else { this.EngineNoHighSource.audioSource = AudioSource.EngineNoHigh; this.EngineNoHighSource.audioSource = this.EngineNoHigh; } if (this.drivetrain.rpm > 8900f) { this.EngineHighSource.audioSource = AudioSource.EngineHigh; this.EngineHighSource.audioSource = this.EngineHigh; } else { this.EngineNoHighSource.audioSource = AudioSource.EngineNoHigh; this.EngineNoHighSource.audioSource = this.EngineNoHigh; } if (this.drivetrain.rpm > 9000f) { this.EngineHighSource.audioSource = AudioSource.EngineHigh; this.EngineHighSource.audioSource = this.EngineHigh; } else { this.EngineNoHighSource.audioSource = AudioSource.EngineNoHigh; this.EngineNoHighSource.audioSource = this.EngineNoHigh; } } public void rpmVal() { this.rpmOnValue = Mathf.Clamp(this.drivetrain.rpm, this.drivetrain.minRPM, this.drivetrain.maxRPM) / 10000f; } private void Start() { drivetrain= GetComponent<Drivetrain>(); this.backgroundMat.color = this.backgroundColor; this.IdleSource.audioClip = AudioClip.EngineLow; this.EngineLowSource.audioClip = AudioClip.EngineLow; this.EngineLowSource.audioClip = AudioClip.EngineLow; this.EngineLowSource.audioClip = AudioClip.EngineLow; this.EngineMedSource.audioClip = AudioClip.EngineMed; this.EngineMedSource.audioClip = AudioClip.EngineMed; this.EngineMedSource.audioClip = AudioClip.EngineMed; this.EngineHighSource.audioClip = AudioClip.EngineHigh; this.EngineHighSource.audioClip = AudioClip.EngineHigh; } void FixedUpdate(){ if (drivetrain){ float factor=drivetrain.rpm/drivetrain.maxRPM; engineNoLoweSource.volume = Mathf.Clamp01((1 - drivetrain.throttle)*engineNoLowVolume*factor); engineNoLowSource.pitch = 0.5f + engineNoLowPitchFactor*factor; engineLowSource.volume = Mathf.Clamp01(drivetrain.throttle*engineLowVolume*factor + engineLowVolume*0.3f*factor); engineLowSource.pitch = 0.5f + engineLowPitchFactor*factor; engineNoMedSource.volume = Mathf.Clamp01((1 - drivetrain.throttle)*engineNoMedVolume*factor); engineNoMedSource.pitch = 0.5f + engineNoMedPitchFactor*factor; engineMedSource.volume = Mathf.Clamp01(drivetrain.throttle*engineMedVolume*factor + engineMedVolume*0.6f*factor); engineMedSource.pitch = 0.5f + engineMedPitchFactor*factor; engineNoHighSource.volume = Mathf.Clamp01((1 - drivetrain.throttle)*engineNoHighVolume*factor); engineNoHighSource.pitch = 0.5f + engineNoThrottlePitchFactor*factor; engineHighSource.volume = Mathf.Clamp01(drivetrain.throttle*engineHighVolume*factor + engineHighVolume*0.9f*factor); engineHighSource.pitch = 0.5f + engineHighPitchFactor*factor; } } } ------------------------------------------------------------------ please help me, and I will be grateful for life!
  8. rpm I have a timer which rotates through the drivetrain (works perfect) I want to do is this .. every certain number of degrees to rotate the needle, play a sound, and "sound pitch" eg the needle is at 55 degrees (playing a sound) = idle rotating and exceeding 56 degrees (it plays another sound (low) and stops ringing above (idle)) and so susecivamente with other 3 sounds .. (med - high - limiter) the question is, how do I add the 5 sounds to script to rotate x degrees is activated and the previous sound stop playing (55 º - 56 idle play) - (56 º -100 º play low and stop idle) etc. .. here the script: if (tachoMeterNeedle) { tachoMeterNeedleRect=new Rect(tachoMeterRect.x + tachoMeterRect.width/2 - tachoMeterNeedleSize.x*0.5f , tachoMeterRect.y + tachoMeterRect.height/2 - tachoMeterNeedleSize.y*0.5f, tachoMeterNeedleSize.x, tachoMeterNeedleSize.y); pivot = new Vector2(tachoMeterNeedleRect.xMin + tachoMeterNeedleRect.width * 0.5f, tachoMeterNeedleRect.yMin + tachoMeterNeedleRect.height* 0.5f); if (RPMFactor<1f) RPMFactor=1f; if (drivetrain) actualtachoMeterNeedleAngle=drivetrain.rpm/(RPMFactor*10) + tachoMeterNeedleAngle; Matrix4x4 matrixBackup = GUI.matrix; GUIUtility.RotateAroundPivot(actualtachoMeterNeedleAngle, pivot); GUI.DrawTexture(tachoMeterNeedleRect, tachoMeterNeedle); GUI.matrix = matrixBackup; Total script also left to be seen and can help
  9. Hello how are you? would need to help me with something I do not understand. I am using unityCar, and everything is perfect, very good .. but I have a problem I do not understand and I can not fix ... I drive the vehicle at high speeds (350 kmh) and destabilizes the car loses grip of the road .. which when you want to turn left or right wheels lose grip .. unitycar have used some of you? someone had this error and fix it? I'm from Argentina .. forgive me if I do not understand .. I hope you can help if anyone has unityCar, and wants. Ask Me and I think a post for everyone. bye
×
×
  • Create New...