generate a gameobject

Asked 2 years ago, Updated 2 years ago, 67 views

Is there a way to generate game objects in a script?
Specifically, after destroying the original gameobject, another gameobject is placed on the spot
It's like generating

I tried using Instantiate(gameobject), but only gameobject(clone)
The gameobject is not on the screen, so it seems that it cannot be generated.

Is there a way to do the above? unity2dc#

c# unity3d

2022-09-30 17:50

1 Answers

Unity and C# It's been 2 months since I started, and I'll answer to the best of my understanding.

I think GameObject is like a soul.The soul has no body, so even if you create a GameObject, you can't see it on the screen.
If you add something like Mesh or Mesh Renderer that corresponds to the body to GameObject, you'll see it, but you can do the following as a simple way.

GameObject myGO=GameObject.CreatePrimitive(PrimitiveType.Cube);

The above allows you to create GameObjects with Cube exterior (+various).

http://docs.unity3d.com/ScriptReference/GameObject.CreatePrimitive.html

Also, GameObject can be processed with only a script without an exterior.In terms of design, we can create an EmptyGameObject and add a script to it.This corresponds to an invisible ghost (angel, devil, whatver) doing something behind the scenes.


2022-09-30 17:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.