[Solved] Unity3D transform like mirror?

Put an empty gameobject at the bottom of your screen. Add a collider(Box collider can do) to it and make it isTrigger and position it just below your screen. Write a code and add it to that empty gameObject with collider to check if any of your object is interacting that collider. void OnTriggerEnter() if(other.gameObject.tag … Read more

[Solved] Array index is out of range but the index is zero and array length is 300

To be honest I didn’t fully understand your code sample, but in the following IF-block: if(b>1 || l<Laenge) b can still be 0 because it’s an OR statement, so later inside this IF-block the statements new_Ver[n]=new_Ver_s[l,b-1]; new_UV[n]=new_UV_s[l,b-1]; will try to index at -1. 2 solved Array index is out of range but the index is … Read more

[Solved] I don’t know how to do

Don’t use the names of existing types as namespaces. You have a custom namespace here: namespace UnityStandardAssets.Characters.ThirdPerson.NavMeshAgent So anything within that namespace (or in code which references the enclosing namespace) which refers to NavMeshAgent will be referring to the namespace. Not to the type in Unity. Rename your namespace. For example: namespace UnityStandardAssets.Characters.ThirdPerson.MyNavMeshAgent (Or something … Read more

[Solved] Attach an object to another object [closed]

if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) if (hit.collider == this.gameobject) // this can be checked on parent or child, your call this.transform.parent = yourParentObject; } 1 solved Attach an object to another object [closed]

[Solved] Get number of children a game object has via script

EDIT 1: A simple variable transform.hierarchyCount, has been added to Unity 5.4 and above. This should simplify this. OLD answer for Unity 5.3 and Below: transform.childCount provided by Adrea is usually the way to do this but it does not return a child under the child. It only returns a child that is directly under … Read more

[Solved] Child of the parent acting like him [closed]

So this seems pretty much messed up situation here. First of all I would advice you to read answers from here and here to get an Idea of whats happening in your game. Now lets try to solve the issue based on what information you have shared in your question. I assume that the magnet … Read more

[Solved] How to bringback an object to its original position after rotation in unity?

I want the cube to return back to its original position when the user stopped touching the cube I can’t exactly tell which part of this you are struggling with but you can simply get the position of the GameObject in the Start or Awake function then set the transform.position to that value when OnMouseUp … Read more

[Solved] How to know if the object is moving upward or downward?

Assuming that the object has a rigidbody, you can use this in the update method (or anywhere for that matter) of a MonoBehavior attached to your GameObject. Rigidbody rb = GetComponent<Rigidbody>(); float verticalVelocity = rb.velocity.y; If you want the velocity along any axis, you can use the dot product: Rigidbody rb = GetComponent<Rigidbody>(); Vector3 someAxisInWorldSpace … Read more

[Solved] Generate 10 unique integers in C# for Unity

Is this what you’re trying to say? If not, please specify how you mean further. This code should give you a number between 1-10 that hasn’t been already used. This code will only work 10 times. Random rnd = new Random(); List<int> usedNumbers = new List<int>(); public int RandomNum(){ int number; do { number = … Read more

[Solved] How To Call Function Which Contains Parameter In Any Other Function Of Other Script?

You should use GetComponent<“ScriptName”>.StartGrab(), in which ScriptName is the name of the script that contains StartGrab(). Note that as your method has 3 parameters, when you call it, you should pass them, or else you’re gonna get compiler errors. For example: GetComponent<“ScriptName”>.StartGrab(objectToGrab, grabbedObject, objectController); You are now correctly calling the method. Note that objectToGrab, grabbedObject … Read more

[Solved] Switch vs dictionary with double keys

Your business logic is a bit unclear, but in regards to the Dictionary object initialization/performance issue, the solution below may serve as a valid alternative. Pertinent to your use-case, you can declare Dictionary<double, int> as shown in the following sample C# code snippet: public static Dictionary<double, int> SampleDictionary =new Dictionary<double, int> { { 3.1, 3}, … Read more