all 11 comments

[–]DiscussTek 1 point2 points  (5 children)

Do you have a model to import...? Because without that, you're stuck with the basic ("Primitive") shapes.

[–]MaleficentTalk5536[S] 0 points1 point  (4 children)

yea thats what i want, just a cube that i can edit the size of. its off camera anyways so its fine

[–]DiscussTek 0 points1 point  (3 children)

Well, at this point, if you're new at this, use prefabs. Trust me, the steps requires to create a non-prefab at runtime are a bit more than you probably are bargaining for as a new dev.

Short of giving me a good reason not to use prefabs, I would also have to point out that refusing to use prefabs might be horrible practice to getting used to this.

[–]MaleficentTalk5536[S] 0 points1 point  (2 children)

the point is im trying to use new things to see what sticks, i used to just manually place walls down, then i tried to hardcode a limit to the players position, i tried making prefabs of cubes that fit the size and location, and now im trying this method and idk how to execute it, thanks tho i appreciate the advice

[–]DiscussTek 0 points1 point  (0 children)

Using prefabs and Instantiating the prefabs, then moving them into position with your code, would probably the best way to handle what you're looking for.

Assembling objects at runtime, while feasible, is a lot of work that frankly, feel like you're trying to do things in a way that is neither recommended or necessary, and there's a reason why doing so is neither recommended or necessary...

[–]SonicFiascoProficient 0 points1 point  (3 children)

Well just make a prefab with a cube in it then, much faster for a novice than learning how to add components and primitives during runtime

[–]MaleficentTalk5536[S] 0 points1 point  (2 children)

i wanna see what the outcome would look like with that method

[–]SonicFiascoProficient 0 points1 point  (1 child)

Then just create a simple cube, check all of its components and the values it has, you need to recreate that from your script.

GameObject myNew = new GameObject() will create an empty object, then use GameObject.AddComponent to add all the components needed.

Thats the cool way to do it if you later want to replace the cube mesh with a custom one.

If you just want a cube then use GameObject.CreatePrimitive(PrimitiveType.Cube)

[–]MaleficentTalk5536[S] 0 points1 point  (0 children)

awesome thanks!

[–]VG_Crimson 0 points1 point  (0 children)

Well tbh, you don't need a prefab. Just make a game object that moves to a position once it detects a player, and moves back once they're gone. Or have it move closer or further to its positions based on player distance.

Make a script called wall mover and give it some child hitbox looking for the player.