logo
down
shadow

Active/Deactive Game object don't work for me in unity


Active/Deactive Game object don't work for me in unity

By : Fortuna
Date : November 19 2020, 03:01 PM
Hope that helps You will not be able to Find the gameobject if it is deactivated. You could store a reference to the object and deactivate/activate it afterwards instead.
code :
    GameObject[] lights = new GameObject[26];
    for (int i = 0; i < 26; i++)
    {
        lights[i] = GameObject.Find("light" + i.ToString());
        lights[i].SetActive(false);
    }

    for (int j = 0; j < 26; j++)
    {
        lights[j].SetActive(true);
    }


Share : facebook icon twitter icon
Unity - How do I apply an animation from one game object to another rigged game object?

Unity - How do I apply an animation from one game object to another rigged game object?


By : user2978535
Date : March 29 2020, 07:55 AM
hope this fix your issue Mecanim performs retargeting of humanoid animations, so for what concern that specific case, you should be able to use the same rig and set of animation clip on different models.
For what concern grabbing furniture, you don't need the object to be rigged. You can use IK to precise move your character's hand toward the target object and then parent it to the relative joint in the hierarchy.
Unity 3D: draw line behind game object/record path taken by game object?

Unity 3D: draw line behind game object/record path taken by game object?


By : simx
Date : March 29 2020, 07:55 AM
this one helps. You need to store the Player's path in List as Vector3. Then you can use LineRenderer to draw the line.change the vertext amount of the LineRenderer to List.Count with LineRenderer.SetVertexCount then loop over the List and change the position of the LineRenderer with LineRenderer.SetPosition(loopIndex,playersPo[loopIndex]).
code :
List<Vector3> playerPos = new List<Vector3>();

//Store players positions somewhere
//playerPos.Add(pPos);
//playerPos.Add(pPos); 
//playerPos.Add(pPos);


Color red = Color.red;
LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
lineRenderer.SetColors(red, red);
lineRenderer.SetWidth(0.2F, 0.2F);

//Change how mant points based on the mount of positions is the List
lineRenderer.SetVertexCount(playerPos.Count);

for (int i = 0; i < playerPos.Count; i++ )
{
    //Change the postion of the lines
    lineRenderer.SetPosition(i, playerPos[i]);
}
Is there a more efficient way to disable multiple scripts while keeping some active on a single game object in Unity?

Is there a more efficient way to disable multiple scripts while keeping some active on a single game object in Unity?


By : user1596099
Date : March 29 2020, 07:55 AM
I wish this helpful for you First of all, the GetComponent<> is quite costly. Don't do it in Update if you can avoid it.
Avoiding means: if these components stay the whole time, you can cache the references:
code :
private List<GameObject>() all_components = new List<GameObject>();
void Start()
{
    foreach(Component c in transform.children)
    {
        all_components.Add(c);
    }
    // Or even GetComponentsInChildren, where (true) includes the inactive gameobjects!
}
all_components.Add(GetComponent<_2dxFX_HSV1>());
all_components.Add(GetComponent<_2dxFX_HSV2>());
// and so on... (but in Start - so just once per runtime :))
public Gameobject[] all_components_array;
for(int i = 0; i < all_components.Count; i++)
{
    all_components[i].SetActive(false);
}
all_components[4].SetActive(true);
all_components[9].SetActive(true);
Unity 2d Game dont show 3d text

Unity 2d Game dont show 3d text


By : Cristi B
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Your camera's z position is -10 and its "near" clipping plane is 0.3 so anything with a z position less than -9.7 won't be rendered by that camera. Your New Text object's z position is -9.9. Set it to 0.
how to add C# script that creates and Instantiates a Game Object in Unity game

how to add C# script that creates and Instantiates a Game Object in Unity game


By : testuser
Date : March 29 2020, 07:55 AM
seems to work fine You have 3 Major Problems. It is the flow of your code.
1 . You're adding a component to an Object Class not a GameObject Class. The AddComponent is a member class of GameObject.
shadow
Privacy Policy - Terms - Contact Us © voile276.org