• Unity3D - Discussion
    5,004 replies, posted
Does it have to be GUI Texture icon? Why not use GUI.Button instead? [code] if(GUI.Button(new Rect(screenPos.x - size_x/2,Screen.height - (screenPos.y - size_y/2),size_x,size_y), TextureImageHere, "")) { // Stuff here }[/code] [url=https://dl.dropboxusercontent.com/u/7422512/Unity3D/button/button.html]Unity example here[/url] Value v is from Vector3 v = Camera.main.WorldToScreenPoint(transform.position);
[code] private WebCamTexture webCamTexture; void Start () { webCamTexture = new WebCamTexture(); webCamTexture.Play(); } [/code] made my day. [editline]29th April 2013[/editline] been playing around with pulling volume from audiolisteners, result: [url]http://nlan.org/unity/music/[/url]
[QUOTE=Silentfood;40460485][code] private WebCamTexture webCamTexture; void Start () { webCamTexture = new WebCamTexture(); webCamTexture.Play(); } [/code] made my day. [editline]29th April 2013[/editline] been playing around with pulling volume from audiolisteners, result: [url]http://nlan.org/unity/music/[/url][/QUOTE] What's the song?
Small amount of work this afternoon trying out different layouts and effects for an overworld/overview map for our game. Ignore the crappy planet textures, and also don't have the full version of NGUI yet, but we are using it as the main GUI for the game and have got panel switching without colliding working pretty well. Also have got save game implementation mostly in using UnitySerializer, can save/restore games and in current version switch between overview map and planets without losing information. But for now, this is what I have so far for the overview map. Lot of work still to be done. LMB - Rotate Scroll - Zoom LMB Click - Display Planet/Sun Name [url]https://dl.dropboxusercontent.com/u/10044881/TestOverview/TestOverview.html[/url]
[QUOTE=Asgard;40463515]What's the song?[/QUOTE] Uppermost - Faster
[QUOTE=Huacati;40463607]Small amount of work this afternoon trying out different layouts and effects for an overworld/overview map for our game. Ignore the crappy planet textures, and also don't have the full version of NGUI yet, but we are using it as the main GUI for the game and have got panel switching without colliding working pretty well. Also have got save game implementation mostly in using UnitySerializer, can save/restore games and in current version switch between overview map and planets without losing information. But for now, this is what I have so far for the overview map. Lot of work still to be done. LMB - Rotate Scroll - Zoom LMB Click - Display Planet/Sun Name [url]https://dl.dropboxusercontent.com/u/10044881/TestOverview/TestOverview.html[/url][/QUOTE] Very cool :)
[img]http://files.bytecove.co.uk/oh.png[/img] So close..
more work, changed the bottom plane into a cube [img]http://i.imgur.com/efLUmVY.png[/img] [url]http://nlan.org/unity/music2/[/url]
That's pretty kewl! I did something similar, but with the mic. How are you reading the volume? My (lousy experimental) script looks like this. [code]using UnityEngine; using System.Collections; using System; public class MicTest : MonoBehaviour { public GameObject cubeCopy; AudioClip recording; float LastVolume = 0.0f; int LastPos = 0; public GameObject[] ObjectList; // Use this for initialization void Start () { recording = Microphone.Start( null, true, 10, 44100 ); ObjectList = new GameObject[100]; for ( int i=0; i < 100; i++ ) { ObjectList[i] = (GameObject) Instantiate( cubeCopy, new Vector3( 0, 10 + i, 0 ), new Quaternion() ); } } float CountData( int iPos, int iSize ) { int iTotalSize = recording.samples; float total = 0; // Trim if we're under if ( iPos < 0 ) { total = CountData( iTotalSize + iPos, iPos * -1 ); iSize -= Math.Abs( iPos ); iPos = 0; } // Handle overspill if ( ( iPos + iSize ) > iTotalSize ) { int overage = ( iPos + iSize ) - iTotalSize; total = CountData( 0, overage ); iSize -= overage; if ( iSize == 0 ) return total; } float[] data = new float[iSize]; recording.GetData( data, iPos ); for ( int i = 0; i < iSize; i++ ) { total = Mathf.Max( Mathf.Abs( data[i] ), total ); } return total; } // Update is called once per frame void Update () { int CurrentPos = Microphone.GetPosition( null ); if ( CurrentPos < LastPos ) LastPos -= recording.samples; float Samples = CurrentPos - LastPos; if ( Samples < 5 ) return; float avg = CountData( CurrentPos - (int)Samples, (int)Samples ); //avg /= Samples; LastVolume = ( avg + ( LastVolume ) ) / 2.0f; transform.position = new Vector3( 0, LastVolume * 5.0f, 0 ); LastPos = CurrentPos; if ( LastVolume > 0.5f ) { foreach ( GameObject obj in ObjectList ) { if ( obj.rigidbody.velocity.magnitude > 0.1f ) continue; obj.rigidbody.AddForce( LastVolume * 100.0f * UnityEngine.Random.Range( -0.5f, 0.5f ), LastVolume * 1000.0f * UnityEngine.Random.Range( 0.5f, 1.0f ), LastVolume * 100.0f * UnityEngine.Random.Range( -0.5f, 0.5f ) ); } } } } [/code]
Found a handy function that pulls samples currently from the audio listener, you add channel 0 and 1 together and you get your true volume. Turns out that both channels aren't that much different, so I tried experimenting with different channels for different lights. No real difference, but it was worth a shot. [code] using UnityEngine; using System.Collections; public class CameraController : MonoBehaviour { public GameObject lightRed; public GameObject lightYellow; public GameObject lightGreen; public GameObject lightBlue; public GameObject cubePrefab; public int blockCount; private float[] samples; private GameObject[] blocks; // Use this for initialization float GetRMS(int channel) { float sum = 0; AudioListener.GetOutputData(samples, channel); for (int i=0; i < 4096; i++) { sum += samples[i]*samples[i]; } return Mathf.Sqrt(sum/4096)*4; } void Start () { samples = new float[4096]; blocks = new GameObject[blockCount]; audio.Play(); for (int i=1; i < blockCount; i++) { GameObject block = Instantiate(cubePrefab, new Vector3(0,i,0), Quaternion.identity) as GameObject; blocks[i] = (block); } } // Update is called once per frame void Update () { } void FixedUpdate() { lightRed.light.intensity = GetRMS(0); lightBlue.light.intensity = GetRMS(0); lightYellow.light.intensity = GetRMS(1); lightGreen.light.intensity = GetRMS(1); Vector3 newPos = new Vector3(transform.position.x, (GetRMS(1)*2)-20, transform.position.z); transform.position = newPos; for (int i=1; i < blockCount; i++) { if (blocks[i].rigidbody.IsSleeping()) { blocks[i].rigidbody.WakeUp(); } } } } [/code] Only transitioned from JavaScript to C# yesterday when making this, turns out there's not much too it to be honest. [editline]29th April 2013[/editline] Also I tried working with the Microphone options, but my efforts always concluded to a distorted version of my voice or my voice lagging behind a few seconds if I un-focus for a while. Strange because my microphone supports all frequency levels.
I only want 4 directions of movement for my XBOX controller. Would this be a good way to find the most dominant axis? [code] if( ( Input.GetAxis( "Horizontal" ) >= Input.GetAxis( "Vertical" ) && Input.GetAxis( "Horizontal" ) > 0 ) || ( Input.GetAxis( "Horizontal" ) <= Input.GetAxis( "Vertical" ) && Input.GetAxis( "Horizontal" ) < 0 ) ) { Debug.Log( "horizontal" ); } else if ( Input.GetAxis( "Horizontal" ) != 0 || Input.GetAxis( "Vertical" ) != 0 ) { Debug.Log( "vertical" ); } [/code]
[media]http://www.youtube.com/watch?v=h4x9hgrPUiQ&feature=share&list=UUCa626L6xBS2LnHlJA_0grA[/media] Not sure if I've posted this here before but I also tried to do something with audio in Unity as well.
Since we're showing off music and audio visualizers, here's an old one I made during an IT class a while back. Q and A toggle glow and anti-aliasing if you want to. [t]http://puu.sh/2JvIZ.png[/t] [url=http://jameswilko.com/unity/musicvis/]http://jameswilko.com/unity/musicvis/[/url]
took a break from what I should have be doing to make my first thing in unity, tried replicating what silentfood did above, dove in blind and it was simple enough. [url]http://jimbomcb.net/unity/2/2.html[/url]
Very tempting to jump on this music visualiser bandwagon, I've never made one before... Fuck it, lets do this...
[QUOTE=TM Gmod;40472110]Very tempting to jump on this music visualiser bandwagon, I've never made one before... Fuck it, lets do this...[/QUOTE] Remember to enable anti aliasing, will make your project look 1000x nicer as figured out today.
[QUOTE=Silentfood;40472174]Remember to enable anti aliasing, will make your project look 1000x nicer as figured out today.[/QUOTE] How do you make Unity's physics engine not suck ass and let objects fall through things?
[QUOTE=TM Gmod;40472522]How do you make Unity's physics engine not suck ass and let objects fall through things?[/QUOTE] Un-tick box collider on the element you want no collisions on.
So since no one seemed to answer my earlier question. Does anyone know any good books on using C# with unity? Pref for a beginner with some/medium experience in other languages.
[QUOTE=Neddy;40473052]So since no one seemed to answer my earlier question. Does anyone know any good books on using C# with unity? Pref for a beginner with some/medium experience in other languages.[/QUOTE] I don't really know of any books for Unity that use C# since most that I've come across in-person have used java/unity-script, but take a look at this list: [url=http://gamefromscratch.com/page/Unity-Book-Roundup.aspx]http://gamefromscratch.com/page/Unity-Book-Roundup.aspx[/url] Even if you can't find a book for C#, you can look up the C# implementation for nearly every function on the scripting reference anyway, you just have to change it to show the examples in C# instead. Theres also a couple of good examples on [url=http://unitygems.com/]Unity Gems[/url] for some more advanced things and a couple of helpers for beginners too.
[QUOTE=Silentfood;40472913]Un-tick box collider on the element you want no collisions on.[/QUOTE] I meant I wanted it to stop doing that, I figured it out anyway, physics weren't continuous. anyway I got kinda distracted, my visualiser looks like all your guys, it works, but I got caught up trying to let the user play music from file. EDIT: 5AM. Done :) [media]http://www.youtube.com/watch?v=_dpCHXE16LQ[/media]
Oh man, I wanna get in on this
Does anyone here have any experience with creating servers for Unity3D, and is willing to answer some questions?
[QUOTE=TM Gmod;40473651]I meant I wanted it to stop doing that, I figured it out anyway, physics weren't continuous. anyway I got kinda distracted, my visualiser looks like all your guys, it works, but I got caught up trying to let the user play music from file. EDIT: 5AM. Done :) [media]http://www.youtube.com/watch?v=_dpCHXE16LQ[/media][/QUOTE] Oh man, can you explain me how you did the file browsing, I've been looking for ways to do it. Also it is possible to read files from any local directory?
here's a screenshot from a ludum dare game i worked on. it should probably confuse you [IMG]http://i.imgur.com/XThZvUA.png[/IMG]
[QUOTE=Eric95;40483586]here's a screenshot from a ludum dare game i worked on. it should probably confuse you [IMG]http://i.imgur.com/XThZvUA.png[/IMG][/QUOTE] Mole monsters, oh god I hate those buggers.
[QUOTE=nVidia;40482711]Oh man, can you explain me how you did the file browsing, I've been looking for ways to do it. Also it is possible to read files from any local directory?[/QUOTE] Sure, the file browsing window you see is a plugin called UniFileBrowser, you call it and it will start a function passing the parameter "pathToFile" and all you need to do then is the i/o with that fill address. For loading off the disk, you have to make the path a WWW class object. on PC you can only use OGG vorbis and a few other formats that aren't mp3 (some annoying license issue) then you wait for WWW to retrieve the path, and load the file . Here's my crappy example. [code] WWW www = new WWW("file://"+pathToFile); yield return pathToFile; AudioClip clip; if(pathToFile.EndsWith(".mp3")) { www.GetAudioClip(false,true,AudioType.MPEG); } else if(pathToFile.EndsWith(".ogg")) { www.GetAudioClip(false,true,AudioType.OGGVORBIS); } yield return www.audioClip; clip = www.audioClip; if(www.audioClip.isReadyToPlay) { Debug.Log(www.audioClip.isReadyToPlay); audio.Stop(); audio.clip = clip; audio.Play(); StopCoroutine("OpenFile"); } [/code] The reason the mp3 one is in there is from trying to get it to work on Android which can use MP3.
Would it be a good idea to use Unity's built-in networking for a large centralized server, or is it better to use the .NET Sockets and make my own?
We are competing for [url]http://daretobedigital.com/[/url] Here is our bare minimum prototype. QWE/123 to resize arrow keys to move up and down. [url]http://mattisdelerud.com/sizeDOSmatter/web/web.html[/url] This thread made me moist for music visualizing.
[QUOTE=AtomiCasd;40487454]We are competing for [url]http://daretobedigital.com/[/url] Here is our bare minimum prototype. QWE/123 to resize arrow keys to move up and down. [url]http://mattisdelerud.com/sizeDOSmatter/web/web.html[/url] This thread made me moist for music visualizing.[/QUOTE] That's a very neat idea! Since you're already moist for it you should take the chance and add a visualizer to the back.
Sorry, you need to Log In to post a reply to this thread.