w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » UNITY3D » Page 1
Integrating Admob into Unity 3d Game
Update your android sdk to latest version copy "android-sdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_lib" this folder to your "AssetsPluginsAndroid" folder Update/Check your AndroidManifest.xml (min, max, targetsdkversion)

Categories : Unity3d

Which Unity version deprecated PostProcessBuildplayer?
Are you in a Mac environment? It hasn't been deprecated AFAIK. It is working for me on 4.5.5f1: $ vi Assets/Editor/PostProcessBuildPlayer #!/bin/sh open "http://google.com" $ chmod +x A When I build I see it open up my web browser. For a cross-platform build solution Unity recommends using the Build Player Pipeline

Categories : Unity3d

Capturing full background with camera view in 2d
You have to change the Viewport Rect on the editor. You can check out Unity3D Manual for more knowledge on Cameras in Unity3D.

Categories : Unity3d

How to change a sprite to another and then back after 1 second
This can be implemented several ways, however, I would use a method that returns an IEnumerator like so… This assumes you have a variable in your script that has a reference to the SpriteRenderer that is attached to the GameObject with this script. SpriteRenderer sr = GetComponent <SpriteRenderer> (); I also assume you have an original sprite and the possible sprites to change to as va

Categories : Unity3d

Rotate Quaternion by an offset?
Here the issue is not is C# or in Unity, the values you are using causes the output values to be (0.0, 0.0, 0.0, 0.0). It can be mathematically explained as below. The quaternions have the form of q = q0 + iq1 + jq2 + kq3 and r = r0 + ir1 + jr2 + kr3 The quaternion product has the form of t= q×r = t0 + it1 + jt2 + kt3, where t0 = (r0q0−r1q1−r2q2−r3q3) t1 = (r0q1+r1q0−r2q3+r3q

Categories : Unity3d

Bounding Box vs. Rectangle
The basic difference is 2d vs 3d. You cannot define the boundary of a 3d object with a 2d rectangle. In theory you could use a Bounds instead of a Recto (by setting one axis to 0), but not a Rect instead of a Bounds. There would be a small perf loss since Bounds require more data. Abbot's Flatland is a classic overview of interactions between 2d and 3d space

Categories : Unity3d

Make objects between camera and character transparent
This is my final code. Note it only makes transparent one object at a time, but the same implementation can easily be done with RaycastAll and using an array for oldHits. public class Camara : MonoBehaviour { RaycastHit oldHit; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } void FixedUpdate() { XR

Categories : Unity3d

how to destroy an item after collision
You need to check the tag not the name. You could check for name but remember it will have "(Clone)". function OnTriggerEnter(theCollision : Collider) { if(theCollision.tag == "Cube 1") { Destroy(gameObject); Debug.Log("Dead"); } } If you are not sure that you tagged correctly, you can simply use both checks in your if statement. if(theCollision.tag == "Cube 1" |

Categories : Unity3d

Is it possible to load an .so library from unity?
Yes. See the documentation on developing Android plugins. Copy your .so to the Plugins/Android folder, and declare its functions in your Unity scripts like so: [DllImport ("PluginName")] public static extern float FooPluginFunction ();

Categories : Unity3d

2D/Top Down Enemy Follow
The simplest way is to construct a vector from enemy to player and make the enemy move along it: transform.position += (player.transform.position - transform.position).normalized * MoveSpeed * Time.deltaTime;

Categories : Unity3d

Transition camera to another position gradually?
Instead of directly setting the position of the camera every time, you can declare a public Vector3 to use as a target. Then in your Update function, which is called every frame, you can use Camera.mainCamera.transform.localPosition = Vector3.MoveTowards(Camera.mainCamera.transform.localPosition, targetPosition, speed * Time.deltaTime); This will move your camera towards the target position gradu

Categories : Unity3d

NullReferenceException @ OnGUI
You are right that it is telling you that an object doesn't exist. In this case, editorSart07Johnson is null and you are trying to get a property from it (.enabled). The line above calls GetComponent which according to the docs "Returns the component of Type type if the game object has one attached, null if it doesn't." So the answer is that your game object does not have a component of type SART

Categories : Unity3d

Check if camera if facing a specific direction
You can try to achieve this in several different ways. And it is a bit dependent on how precise you mean facing the box. You can get events when an object is visible within a certain camera, and when it enters or leaves using the following functions. With these commands from the moment the box gets rendered with that camera (so even if just a edge is visible) your collision will trigger. OnWillR

Categories : Unity3d

How can I turn the camera to left and right with mouse in unity for a sphere?
You can create a game object to follow the ball with Vector3.Lerp, your camera must be child of that game object and add this script to the game object: transform.Rotate(0,Input.GetAxis("Mouse X"),0);

Categories : Unity3d

apply texture on OBJ files automatically in batchmode
Found the solution! Two files are generated when object file is exported from 3D modelling software, one is the .OBJ and other is .MTL. The latter contains texture map information of that particular object file. If .MTL file is imported along with the .OBJ and textures in the unity project, while exporting asset bundle, unity takes all the textures automatically. When this asset is rendered in th

Categories : Unity3d

In Unity3d using the FPS Controller, how can I keep a constant player speed when auto-walk forward using transform.forward?
Multiply your movement for Time.deltaTime This time is the time between frames. Example copy from http://docs.unity3d.com/ScriptReference/Time-deltaTime.html function Update () { // Move the object 10 meters per second! var translation : float = Time.deltaTime * 10; transform.Translate (0, 0, translation); }

Categories : Unity3d

Turn on collision unity 2d game
void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.name == "NAME_OF_YOUR_MONSTER") { box.transform.Rotate(0,180,0); } } And add this script to your walls. That should work.

Categories : Unity3d

MoPub ads in unity3d
Have you tried mopub's unity pluggin? It's open source and free. http://www.mopub.com/2013/01/18/the-mopub-unity-plug-in-is-now-open-source/ There are 2 pluggins, one to use on android build and another to use with iOS.

Categories : Unity3d

Unity | MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it
It means that the object you are trying to move, change position, etc. id destroyed. Try making a new object called like the object you used in your script. If it doesn't help, post the script in a comment. Have a great day!

Categories : Unity3d

How to use a Visual Gesture Builder database with Unity3D Plugin?
I was running into the same problem. As far as I can tell, you cannot call these constructors directly, but you instead need to call on the static method Create. For example, in your case you would say... _gestureDatabase = VisualGestureBuilderDatabase.Create(@"gestures.gbd"); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_Sensor,0); This seems to resolve the issu

Categories : Unity3d

How can I properly create invalid Vector3 in Unity?
I had a similar problem in the past, I found there was two solutions. The first solution was to create a wrapper for the class. Class Vector3Wrapper { Vector3 vector; } Then I would simply set the Vector3Wrapper to null then if it wasnt null access its vector. A better method would be making it a Nullable type. A example is below. http://unitypatterns.com/nullable-types/ public class Char

Categories : Unity3d

Unity 3d How to create a custom wind to interact with my object?
If you're not using the Tree Creator, then I think the best way would be to rig your tree and animate it "shaking." Then add those animations to your newly imported tree and call the animations as appropriate. There are alternatives, such as reading in vertices from the mesh and moving them or maybe rotating it after adjusting the center of gravity, but I doubt it'll satisfy your needs. If time is

Categories : Unity3d

Unity3d stretch GUI.Box
First find out what is the size of the content with CalcSize. Then use that size to make the box tightly fitted around the content. GUIStyle lBoxStyle = new GUIStyle(GUI.skin.box); lBoxStyle.stretchWidth = true; lBoxStyle.stretchHeight = true; lBoxStyle.wordWrap = true; lBoxStyle.fontSize = 48; lBoxStyle.normal.textColor = Color.Black; // Caculate the size of the cont

Categories : Unity3d

Get transform from mouse click position
There are two ways to do it, which depend on the kind of camera you are using. Attach either script to the object you want to move and you are done. Make sure you put it in the Update(). The Orthographic if(Input.GetMouseButton(0)) { var posVec = Camera.main.ScreenToWorldPoint(Input.mousePosition); posVec.z = transform.position.z; transform.position = Vector3.MoveTowards(transform.p

Categories : Unity3d

How do I access sprite meta data in Unity?
This is perhaps not answering your specific question about the built in sprite sheets, but I use TexturePacker (from CodeAndWeb). They export a config file that allows you to get sprite information similar to what you're asking as well as providing a simple importer that you can work with if you don't need too much control.

Categories : Unity3d

How to programmatically assign a random sprite to game object?
Well, you can generate an array of sprites of the length of your choosing with: Sprite[] _sprites = new Sprite[quantity desired] Then using the resources folder and the Resources.Load method (found here: http://docs.unity3d.com/ScriptReference/Resources.Load.html), you could load all your sprites into the array one after the other. Then using your random number generator, you can access sprit

Categories : Unity3d

raycast not showing hit
So it seems there are two things at work here. First, according to the documentation, Raycast 2D will also detect collider(s) at the start of the ray. If you don't use raycastAll then the source enemy will stop your ray before it goes out into the world. To prevent this you could use a layer mask. Just to be sure, a layer mask signifies the layer that you want to hit, not the layers you want to ig

Categories : Unity3d

Unity3D object doesn't move on rotation
try swapping these two around. void Update () { HandleRay (); Move (); } Then the move should be facing the correct direction when you apply forward.

Categories : Unity3d

Unity prefab with script gets different components in children than other scripts
Well... I figured it out. I was checking to see if the prefab existed before instantiating it and so I was also calling methods in the object before it was actually instantiated. It didn't occur to me that loading a prefab and instantiating it are 2 different instances.

Categories : Unity3d

ApplicationData.persistentDataPath Unity Editor to Android
Directly inside Assets folder, create a folder with name "StreamingAssets" and put your sqlite database file in this folder then use the following code to extract and copy the sqlite database to persistentDataPath: void InitSqliteFile (string dbName) { // dbName = "example.sqlite"; pathDB = System.IO.Path.Combine (Application.persistentDataPath, dbName); //original path string sou

Categories : Unity3d

Unity Render Distance Close
If its the in game camera look in your inspector panel. On your camera game object there should be a property in the inspector name Clipping Planes, change the near one to something like 0.01 If it's not your ingame camera and it's the camera in the scene view, just select an object and press F to reset clipping planes.

Categories : Unity3d

Curled fingers: Unity3d
the bones in your imported model rig must contain all the fingers and other parts bones that doesnt move correctly , if it does then assign them to your avatar as you are setting up your avatar (look here for avatar setup) , after that if your animation animates fingers then your model will also

Categories : Unity3d

GUI.tooltip acts weird for me
The problem is that the tooltip system works a bit strange. The GUI.tooltip is actually set when the control is drawn. So the code responsible for setting the current tooltip is inside the GUIStyle.Draw method. That means the tooltip is only set during the Repaint event and only after the control has been drawn. So your button is drawn but won't receive any input events as the tooltip is not set w

Categories : Unity3d

Child and parents relations Unity
You can use GameObject.AddComponent to add a Component to a GameObject. You can do piece1.parent.gameObject.AddComponent<PolygonCollider2D>(); This function also returns the component itself, as explained in the Unity Documentation: http://docs.unity3d.com/ScriptReference/GameObject.AddComponent.html

Categories : Unity3d

Unity3d C# turret gun projectile won't move
Does the projectile have a script of its own? It doesn't look like you're setting any velocity to the instantiated projectile. Translate() doesn't really perform much in the way of movement, other than immediately setting the new position. If the projectile has a Rigidbody component attached, then you can just directly set the velocity of the rigidbody. Like so: InstantiateedProjectile.velocity

Categories : Unity3d

I am trying to make an object with a velocity that will swap every 2 seconds
The problem is that you have put the code of a Coroutine inside your Update method. So that "yeild" keyword will not work. Also, the line "if (1=1){" is always true - that's a mistake you're probably run into later. Take a look at this tutorial on using corroutines on UnityPatterns.com its what you want.

Categories : Unity3d

GameObject hit doesn't return the correct value
Create a function inside the Tile: public void setBoolean(bool b) { yourBool = b; Debug.Log("Printing the boolean value: " + yourBool); } Then in your collision code: hit.transform.gameObject.SendMessage("setBoolean", true); Or if you prefer: hit.transform.gameObject.GetComponent<Tile>().setBoolean(true);

Categories : Unity3d

Instanciate prefab as child in Unity3D
Try Using This To Force Child To Have It's Own Scale After Being a Child: var localScale = child.transform.localScale; // store original localScale value child.transform.parent = parent; child.transform.localScale = localScale; // force set

Categories : Unity3d

Rotate a GameObject to player position?
You can try this code: float turnspeed=1.0f; //set a turning speed void Update () { dir = player.position - transform.position; dir.Normalize(); transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(dir), turnSpeed *Time.deltaTime); }

Categories : Unity3d




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.