StartCoroutine is a method of MonoBehaviour. So, whichever script actually uses StartCoroutine is actually the object that needs to be active. You may want to try oldAnimal.StartCoroutine(oldAnimal.Flash());...
android,ios,mobile,unity3d,touch
Your trying to call HitTest directly from GUITexture like a static function but HitTest isn't a static function, you need to create a variable from GUITexture class and then call HitTest function from that object like this: public GUITexture guiT; if (guiT.HitTest(touch.position) && touch.phase !=TouchPhase.Ended) { guiT.texture = button2; transform.Translate(Vector3.right*30*Time.smoothDeltaTime);...
This is perfectly natural C#, but it won't fly: sct=new AudioSource(); Unity has a component-driven, factory-based architecture. Instead of calling a component constructor, Unity wants you to call AddComponent to attach the component to a specific GameObject: sct = gameObject.AddComponent<AudioSource>(); There are a few reasons for that. First off, Unity...
This is a known issue at AdColony and we will be releasing a fix in a pending release. We will update this post once it has been released at: https://github.com/AdColony/AdColony-Unity-SDK...
It finally works now. Just had to add these in retrievefromDB() public void retrievefromDB(){ while(true){ if (timeStep - prevTimeStep > 99) { timeStep -= 1; //special for this dataset query = "SELECT * FROM GridData2 WHERE timestep=" + timeStep; if (showParent) query += " AND (Level != 10)"; else query...
Well, since you wrote Items are not going to be dynamically added or removed at runtime. I would suggest creating another field that will be collection of items, and populate it in the constructor of the container class using reflection. Then, in the UpdateAllItems() method you can iterate this collection...
Your Code clearly Saying KeyCode.Escape and not getting space key change that to KeyCode.Space and it'll work
android,unity3d,multiplayer,appwarp
After you connect to AppWrap API using your API key and Secret key (I don't think you should show us those keys in your picture you better remove them) your should create a room or a lobby yourself to interact with other players in it. consider reading Standard User Guide...
From other research (Equals(item, null) or item == null and Unity Forums) and to elaborate on usr's answer: I needed to guarantee that a Component was being passed through in my CheckIfNull header. The updated code looks like this: using UnityEngine; using System.Collections; public class NullChecker : MonoBehaviour { void...
unity3d,unity3d-gui,unity3d-editor
don't use "selected" AND "criteria". you must use the same ONE variable: int selected = 0; ///* string[] options = new string[] { "Start With", "End With", "Contains", }; //selected = EditorGUILayout.Popup("Search Criteria", 2, options); //*/ selected = EditorGUILayout.Popup("Awesome Drop down:", selected, options, EditorStyles.popup); because this is the way your...
Okay, from your Question, it looks like you've checked on Multithreadingin your Build Settings? Disable that, I really doubt you'll have the need to use it. From the picture in your comment, you seem to have used Architecture - Universal. Instead, change that to ARMv7 and as per your question...
android,unity3d,screen,freeze,splash
Okay , I found the solution. It turns out that one of my script was responsible for this problem. So I deleted it and rewrite another script that do the same job. I assume, script was trying to use RAM over and over , so because of that, Adreno 330...
I figured out the reason all my boosts got used in one go, I was using RepeatButton instead of Button. Although this didn't work at first I combined it with (&& boosts > 0) and it now works perfectly :) public void OnGUI() { if (GUI.Button(new Rect(20, Screen.height - 150,...
You need to draw a curve... X,Y,Z components of your curve is coming from the equation you have possibly with sin and cos and then you need to draw a curve by sampling the curve with small increments and connect the samples with lines... This tutorial gives you a good...
As noted above, windows doesn't support MP3, so use OGG or WAV. You must wait for WWW to complete before accessing the clip. And WWW must be loaded in an asynchronouse Coroutine. public void LoadSong() { StartCoroutine(LoadSongCoroutine()); } IEnumerator LoadSongCoroutine() { string url = string.Format("file://{0}", path); WWW www = new...
This is how I would do it if I really wanted to use the switch statement: float someSmallValue = 0.5f; // Adjust this as per your needs if (Vector3.Distance(transform.position, patrolPoints[currentPoint].position) < someSmallValue) { switch (moveType) { case MoveType.Forward: currentPoint++; if (currentPoint > patrolPoints.Length - 1) { currentPoint -= 1; moveType...
this is very simple. use one image as the scale background. use another image as the pointer. set the pivot and anchor of the pointer at the position where you want to rotate it. use transform.Rotate() in your code to rotate the pointer.
audio,unity3d,collision,particles
You can use OnParticleCollision and the ParticlePhysicsExtensions, and play a sound with PlayClipAtPoint: using UnityEngine; using System.Collections; [RequireComponent(typeof(ParticleSystem))] public class CollidingParticles : MonoBehaviour { public AudioClip collisionSFX; ParticleSystem partSystem; ParticleCollisionEvent[] collisionEvents; void Awake () { partSystem = GetComponent<ParticleSystem>(); collisionEvents = new ParticleCollisionEvent[16]; } void OnParticleCollision (GameObject other) { int safeLength...
Unity already provide an unique id for every object instance, have a look at GetInstanceID.
Add an Event Trigger component to your button . From there you can add a listener for OnPointerUp for when mouse is released and OnPointerDown for when mouse is pressed
unity3d,google-play,package,admob
First make a backup of your project and delete your metadata files in your asset project folder and childs. Files with extension .meta
Do not have multiple speed variables, just have one, and call for it every time you need to get it SpeedHolder speedHolder; public void Update() { transform.position += speedHolder.Speed * Time.deltaTime; } If you REALLY want this done another way... you can use events and delegates. public class SpeedHolder {...
Why not just tween it yourself? float x = 0f; IEnumerator TweenLinerenderer() { while(x <= 1f) { myLineRenderer.SetPosition(1, new Vector3(x, 0, 0)); x += Time.deltaTime; yield return null; } x = 0f; } ...
You won't need to purchase any licencing for those platforms. You will need to start paying when your annual turnover is high enough but I doubt you have to worry about that now. See here: https://unity3d.com/get-unity. Unless you make $100 000 a year off of Unity then you can deploy...
float timeCounter = 0; void Update () { timeCounter += Input.GetAxis("Horizontal") * Time.deltaTime; // multiply all this with some speed variable (* speed); float x = Mathf.Cos (timeCounter); float y = Mathf.Sin (timeCounter); float z = 0; transform.position = new Vector3 (x, y, z); } ...
If you are asking about "one click export for Android" then yes it is a one click export for Android Build Settings > Android > Switch platform > Build But for the question will there be any additional work necessary. Well that depends if you have used any (self made...
If you really want to be frame-rate independent you should use a coroutine that's how i'd do it : float startWidth = 1f; float endWidth = 10f; float startPosition = 1f; float endPosition = 10f; float positionX, widthX; IEnumerator SlideInAnimation(float slideTime = 0.3f, float expandTime = 1f) { float t...
Are you sure you want to Instantiate 10 child prefabs on each frame (Update is called once per frame). I think you problem is, that you did not Instantiate the parent prefab. If I take your code, and fix it, it works like a charm for me. public GameObject childPrefab;...
c#,unity3d,msbuildcommunitytasks
As far as I know, you cannot prevent Unity from overwriting your csproj files upon recompilation of your scripts. When working with larger code bases and Unity3D I tend to put most of my code into separate .Net assemblies (DLLs). This helps me when I'm sharing code between multiple projects...
android,ios,unity3d,push-notification,android-notifications
You are right, someone has done that indeed :) I'm one of developers of the new Unity asset UTNotifications. It does all you need and even more. Please also note that there is no single way to implement the Push Notifications to work with any Android device - there is...
c#,arrays,list,unity3d,gameobject
public List<GameObject> myListofGameObject = new List<GameObject>(); Start(){ myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName")); myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName2")); myListofGameObject.AddRange(GameObject.FindGameObjectsWithTag("TagName3")); foreach(GameObject gc in myListofGameObject){ Debug.Log(gc.name); } } Works Perfectly fine for me, Make sure to add the System class for linq generics....
Yes, you need to create a child GameObject, with a trigger collider, and put it in a layer that interacts with the player layer. No, you don't need to add a Rigidbody to the new GameObject, the parent's rigidbody already makes it a dynamic collider, so you will get OnTrigger...
if you have gameController = GetComponent<GameController> (); make sure that PlanetController and GameController are actually on the same game object in your scene. if they are not, you will have to use: http://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html...
Create a GUITexture object: in unity menu: GameObject -> Create GUI Texture, let’s call it darkBackground; Attach a dark texture to darkBackground; Disable darkBackground object (you can do it interactively or programatically call) darkBackground.SetActive(false); When paused, turn on /enable this GUITexture game object by calling darkBackground.SetActive(true); ...
web,unity3d,3d,augmented-reality,unity-web-player
Try this. Furthermore, I would just uninstall everything and just reinstall with a stable version of Unity 5.
You can take your number that ranges from 0 to 500 and simply divide it by 500, e.g. scaled_x = x / 500.0f. Depending on the language and the type of x you will need to divide by either 500 or 500.0f. If you are using a language that has...
When you describe it that way, its much clearer & much simpler. Look at any mobile application: they do not put 6000 people records on a single page. Its normally paged or grouped, with a search option. So do that instead. If you look at the facebook mobile app (a...
In plain vanilla C#, it is not possible for the new operator to return null. It will either return a valid non-null reference, or it will throw an exception. Note, however, that Unity is not "plain vanilla C#". Unity is based on Mono (which in turn is based on .NET),...
The master volume control in Unity is owned by the AudioListener Your code is updating a saved value in PlayerPrefs called VolumeLevel, but it doesn't actually tell Unity to change the volume at any point. To do that globally (i.e. for all sounds at once), you can update AudioListener.volume with...
You must instantiate prefabs like this. PrefabTypeObject obj = (TypeOfPrefab)Instantiate(prefab, position, rotation); or PrefabTypeObject obj = Instantiate(prefab, position, rotation) as TypeOfPrefab; otherwise you will get null object or InvalidCastException like now. Your solution is` clone = (GameObject)Instantiate(swordObject_prefab.gameObject, Player.position, Quaternion.identity); ...
So I am struggling with how to figure out how to make the ball shoot in the direction it is facing depending on how it have been translated in the ball script. Multiply speed by the direction you want to shoot in: // Shoots a ball the longer you...
Those would be RectTransform rectTransform; /*Left*/ rectTransform.offsetMin.x; /*Right*/ rectTransform.offsetMax.x; /*Top*/ rectTransform.offsetMax.y; /*Bottom*/ rectTransform.offsetMin.y; ...
unity3d,particle-system,particle,trail
If you just want to control the direction, using a mesh definitely works. Particles are emitted from the mesh (be it from a vertex, edge or triangle) using the mesh's normal at that point as direction (unless Random Direction is checked), so make sure the mesh's normals are in order....
You could use Math.Min and Math.Max. minXvert = Math.Min(verts[i].x, minXvert); maxXvert = Math.Max(verts[i].x, maxXvert); That would make your code more concise and readable, but won't make it any faster. To make it somewhat faster, you could store x, y, z values in local variables, so they only have to be...
unity3d,unityscript,raycasting
Quaternion.LookRotation((fwd - transform.position).normalized) needs to be Quaternion.LookRotation(fwd.normalized)
Apparently this is a bug with Texture2D.Apply(). It's so deep, Unity's profiler did not show the leak, but external tools did. Unity have acknowledged the problem and are seeking out a solution. No date was given. Thanks for the help :-)
How about this way? bool _isAnimating = false; // Update is called once per frame void FixedUpdate() { if (Input.GetMouseButtonDown(1))//If clicked { clickPosition(); //Gets the click position //start animation here!!! //animator.SetBool("bWalk", false); //and set animation state to true _isAnimating = true; } if (Vector3.Distance(transform.position, mouseClick) > minDistance) { clickToMove(); }...
Since this is a racing game, time to complete the race would be your main scoring factor. The faster the player finishes the race the higher the score. As for your question about passing enemy car you can check that by calculating the distance the player has covered on the...
That article gives a good overview of what is required. However, you can essentially skip almost all those steps when using autodesk character generator. Here is a quick way: Set your FBX to be a mecanim humanoid Drag an mecanim animator controller onto it Write your code to set the...
Your code is perfect. That means one of 2 things: DelayTime is excessively large (debug it out) or, more likely: The GameObject is destroyed so the CoRoutine nolonger is running. Try this: void Start () { guiTexture.pixelInset = new Rect (0, 0, Screen.width, Screen.height); StartCoroutine (LoadNextScene ()); } IEnumerator LoadNextScene(){...
This is essentially a Service Locator "Anti Pattern" that is (surprise surprise) based around the Singleton Pattern. However, instead of retrieving service instances, you are retrieving object instances. Regardless of the name, this actually does NOT create a more modular application. On the contrary, you are creating hard dependencies throughout...
In Unity 5.1, the fixed angle effect is done via Rigidbody2D.constraints. GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; See also RigidbodyConstraints2D....
c#,user-interface,unity3d,uibutton,unityscript
At a guess, your Canvas' CanvasScaler's UI Scale Mode is probably set to Constant Pixel Size, and if your mobile device's resolution is too high, text will appear small. Try changing the UI Scale Mode to Scale With Screen Size and change the properties it provides as needed. (if your...
Given the sole task of "creating an efficient tilemap", your best option is to create a TileMap component that manages a procedural mesh made up of a collection of independent quads with uvs mapped to a tile atlas. This way you will even draw your whole map in one drawcall....
When using the new UI objects, as opposed to the Legacy GUI, you must have the image imported as Sprite/UI. Unity Import Reference...
Have you updated the Android SDK tools to 24.3.2? This seems to have caused the issue. Add following 4 lines to android-sdk-path/tools/ant/build.xml starting line 484 and hopefully it should solve. <property name="aidl" location="${android.build.tools.dir}/aidl${exe}" /> <property name="aapt" location="${android.build.tools.dir}/aapt${exe}" /> <property name="dx" location="${android.build.tools.dir}/dx${bat}" /> <property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" /> ...
is the mouse in unity "captured" in screen resolution or how should I scale the mouse Position to a value between -1 and 1 ? In this case the "normalizedSpeed" will be your target public float mouseDistance; public Vector2 mouseDown = -Vector2.one; public float normalizedSpeed; public void Update() {...
mod-rewrite,unity3d,swf,swfobject
I did some further tests, sadly there are no errors on the console. But it pretty much looks like there's something wrong with your .swf file on the server, because when I download the file from your server it is not working locally either. (Did you try that before?) How...
if (sResult = null) { Should be if (sResult == null) { Single = is an assignment operator so you are setting the result to null instead of checking if it is null....
Lowercase your GameObject to gameObject. GameObject is a type, gameObject is a reference to the attached GameObject. Also you are adding the MeshFilter twice, that is a mistake. Cache your components so you can use them later like this: EDIT: thought your "GetComponent" was another "AddComponent". So i retract my...
Try this: void shootIt() { Vector2 direction = transform.localPosition.normalized; transform.parent = null; isPlaying = true; A.isKinematic = false; A.AddForce(direction*varSpeed*_multiplier); } Also consider forcing yourself to write good names for your variables. A is not very descriptive....
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below). This is verified by opening up the assembly in your reflector tool of choice, here I...
seems like inside Update you are missing a '=' Ie: if (Spawn1 = true) Should be: if (Spawn1 == true) Also to avoid extra processing on Update method you can do this: void Start () { StartCoroutine( AutoSpam() ); } void Update () { // Empty :) } IEnumerator AutoSpam()...
whenever I move the parent of the object, the child stays and no longer moves around the parent Thats because you are moving the sphere via transform.position when it should be transform.localPosition Either that or you could do transform.position = transform.parent.position + new Vector3 (x, y, z); EDIT: personally,...
So after many days of researching and testing hope my answer will help someone who is facing this problem. Assuming you integrated unity with your project and there is no compiling errors. There are 3 files you have to modify in order to get this to work. I’m using Unity...
android,unity3d,libgdx,andengine
It is possible in andEngine to start andEngien activity from basic android activity and the other way: to start normal android activity from andEngine game. You can find examples on StackOverflow. Try to search for "Trouble launching Andengine Activity from OnClickListener" (Sorry, cant paste links right now). Also, isn't it...
c#,user-interface,button,unity3d
Thats exactly why you dont find the location of the point inside of the button itself... but you compare the location of the point inside of the parent rect of the button and the buttons localPosition itself. That or you can translate the pixel point to screen position then compare...
user-interface,unity3d,unity3d-gui
I am going to give you a code snippet of mine because i feel like being helpful. Hope this helps! protected ScrollRect scrollRect; protected RectTransform contentPanel; public void SnapTo(RectTransform target) { Canvas.ForceUpdateCanvases(); contentPanel.anchoredPosition = (Vector2)scrollRect.transform.InverseTransformPoint(contentPanel.position) - (Vector2)scrollRect.transform.InverseTransformPoint(target.position); } ...
I figure someone else might find this useful later so: if(PlayerPrefs.GetFloat("nodeNum") > 0) { //Assemble axis value arrays //X var xString = PlayerPrefs.GetString("xVals"); var xValues = xString.Split(","[0]); //Y var yString = PlayerPrefs.GetString("yVals"); var yValues = yString.Split(","[0]); //Z var zString = PlayerPrefs.GetString("zVals"); var zValues = zString.Split(","[0]); var countNode = 0; var...
You need to instantiate your class Rigidbody before accessing a non-static field such as AddForce. From the documentation bellow : using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public float thrust; public Rigidbody rb; void Start() { // Get the instance here and stores it as a class...
I don't see where you've declared your GUI Skin in the code above. using UnityEngine; using System.Collections; public class InfoInput : MonoBehaviour { public string charname = "Name"; public string usrname = "User Name"; public string charrace = "Race"; public string charclass = "Class"; public string charalli = "LG"; public...
GUI.color = Color.black; makes every button's alpha color higher...
I'll explain how you can achieve this with a simple shader and some setup. I'm speaking from memory so if some problems occur please ask. So what you can do is: Make a new layer for rendering the masks. Let's say we call this layer MaskLayer. Duplicate your main camera....
I am using this method in my project, you can use too. Maybe there is better way, I dont know. public void KMBMaker( Text txt, double num ) { if( num < 1000 ) { double numStr = num; txt.text = numStr.ToString() + ""; } else if( num < 1000000...
Comment is getting Bigger So I will paste it in here. https://www.youtube.com/watch?v=Xx21y9eJq1U In this video try to check the 44:51 ish or something. That is what you need. Then Control it with a script when to activate it. It is a Masking. You can mask the animation and so on....
private GameObject Gobj; is a variable for a single GameObject. Reformat it to private List<GameObject> objects; and instead of Gobj.transform.position = new Vector3 (ObjPosition.x, ObjPosition.y, ObjPosition.z) do this: foreach (GameObject item in objects) { item.transform.position = new Vector3 (ObjPosition.x, ObjPosition.y, ObjPosition.z) } EDIT: In case you aren't sure about how...
I remember reading a fun post Performance numbers in the pub by Ayendy Rahien. How many CLR objects can you create in one second? And here was the result back in 2011 Created 7,715,305 in 00:00:01 Jokes aside. Create is pretty cheap operation but GC is not. So while you...
Simply google it, the following is from: http://answers.unity3d.com/questions/52109/how-do-i-mute-all-audio-sound.html AudioListener.pause = true; AudioListener.volume = 0; try this http://unity3d.com/support/documentation/ScriptReference/AudioListener-pause.html...
The way you wrote it is actually exactly how you want to do it. The method is called recursion. It is a very popular way of achieving what you are trying to do, nothing wrong with having a method calling itself, if done within certain guidelines like meeting certain criteria...
You should attach the script that contains oncollisioneneter to your sprite1 game object for example and in your sprite 2 game object add a tag like sp2 or whatever you want , then in your script when collision happens you check if the object that sprite one collided with is...
Your problem is having a MeshFilter on the same GameObject as your TextMesh What you are seeing is the MeshRenderer drawing the wrong mesh, but using the font's material. Those seemingly random letters is what a font texture atlas actually looks like when textured on a cube. What mesh is...
I think that's because when you move the object, the Unity GameView will lose its focus. So just ensure it has the focus again (klick into it), before hitting the key.
android,unity3d,google-cardboard
I solved the bug myself. This issue was solved by updating my Unity 5 Pro to v5.1.0f3 and Cardboard SDK for Unity v0.5....
android,unity3d,google-project-tango
The example code is Unity 5 based project, so please use the 5.x version of Unity to open it. If you use Unity 4.x version, the scene won't be opened up properly. However, the code lab is based on Unity 4.6 and it is independent from our sample code. I...
c#,unity3d,event-handling,keyboard
Please refer to http://docs.unity3d.com/ScriptReference/Input.GetKey.html Returns true while the user holds down the key identified by name. Think auto fire. If you look at the input class you can find other functions which will be more useful....
ios,unity3d,shader,mesh,particle
You can do it using geometry shaders to create billboarding geometry from each vertex on the GPU. You can then either create the circles as geometry, or create quads and use a circle texture to draw them (I recommend the later). But geometry shaders are not extensively supported yet, even...
Your code explicitly creates ammo with that if statement, as you are turning negative myReserve values into zero. Let me refactor your code, this is exactly what you code does now: var transferedAmmo = magSize - boolet; myReserve -= transferedAmmo; boolet += transferedAmmo; if (myReserve < 0) myReserve = 0;...
c#,unity3d,game-engine,mesh,tile
if you want to scroll uv`s , you can do it by changing the texture offset in Update method , it can be used for background of a 2d game using UnityEngine; using System.Collections; public class ScrollingUVs : MonoBehaviour { public int materialIndex = 0; public Vector2 uvAnimationRate = new...
Image img = null // I assign it via the inspector void Update() { if(Input.GetMouseButtonDown(0)) { Vector2 point; RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)img.rectTransform.parent, Input.mousePosition, canvasCamera, out point); img.rectTransform.anchorPosition = point; } } ...
It's been awhile since I've did Unity coding, so there may be some minor errors with my syntax but it should give you an idea of how to accomplish this. Your best bet for the loop is to use a coroutine to not block the main thread. in Update() check...
var means the compiler will determine the explicit type of the variable, based on the usage. One pro is that it requires less typing to declare variables and it's more readable, but can be used only for local scope variables. Also with var, you don't have explicit reference to type,...
The Background gameobject in the scene overlaps the menu items. Change the position of the Background gameobject to be slightly behind the menu items and OnMouseEnter will register. Also, the line of code that changes the color on the material inside OnMouseEnter doesn't actually change the color of the text...
java,android,unity3d,android-mediaplayer
It would appears that while i have found nothing explicitly states that this CAN be done, there is no real information or any examples of it having been done before. I'll be attempting a re-working of this in native C++ code....