Questions tagged [prefabs]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
29 views

How can I make a health bar — a UI element — part of a character prefab?

Description I want my character prefabs to come with their own health bar, but I can't simply add one as part of the prefab, because it's a UI element and therefore goes into a Canvas. Potential ...
0
votes
1answer
20 views

Prefab not working when I import maps form Tiled using Tiled2Unity

I have correctly created the map using Tiled with no errors or warnings, then i imported the package from tiled2unity, imported the map then waited few seconds and the prefab from tiled2unity appears ...
0
votes
1answer
122 views

Unity: how do I get a list of prefab tiles from the TileMap?

I'm building a 2D strategy game where I've decided to use TileMap for spaces which characters can traverse. My tiles need to be prefabs, because they will have a script attached to them to store ...
0
votes
1answer
16 views

Unity: Sprite stretch issue

I have a simple png square 8px x 8px. In Unity I've left the pixels per unit at 100 and added the image to the scene to create a prefab of the item. I then add four items to the screen like so: ...
0
votes
1answer
19 views

Check if 2 objects with multiple colliders overlap using bounds

I'm writing a script which instantiates buildings in a scene, but in such a way that 2 buildings don't overlap with each other. Every building consists of approx. 10 parts, of which each has a box ...
-1
votes
1answer
25 views

NullReferenceException when translating instantiated prefab [duplicate]

I keep getting this error: NullReferenceException: Object reference not set to an instance of an object moveBlock.Update () (at Assets/Scripts/moveBlock.cs:27) whenever I press Play in Game or when ...
0
votes
0answers
40 views

I have 240 prefabs to scatter, what is the best way to achieve this?

I'm creating a huge city for which I've made 240 different building prefabs. Now I need to scatter those prefabs randomly with a height, width and depth and rotation randomness variation. I thought ...
0
votes
1answer
38 views

Unity hangs when saving prefab asset

For game saving purposes, I'm keeping track of references to ScriptableObjects through a lookup table, so that I can serialize/deserialize using the SO's position in that table. I have a lot of ...
0
votes
1answer
244 views

Using Part of prefab as script parameter

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to ...
0
votes
0answers
12 views

Prefabs scaling change also the original prefab

I want to work with a prefab as local and global variable? something like that. So my question is how to change a prefab scale without affecting the original prefab.
0
votes
1answer
25 views

Unity 3D platform spawning problems

I'm making an infinite runner game in Unity 3D. I have it so that platforms spawn and move backwards toward the player and they are destroyed once past the player. Over time when the platforms are ...
0
votes
1answer
27 views

Unity: How can I control a Shadergraph effect on multiple enemies with the same prefab?

So I made a simple White Flash -> Dissolve effect with shader graph 2D, it's my 1st time using shaders. I'm controlling the effect using a float inside the shader, with: ...
0
votes
1answer
20 views

List to hold copies of a prefab for later deletion

I'm working on a game in which obstacles are Instantiated randomly 5 to 20 units ahead of the player. When they are instantiated, I want to add them to a list so that when there are too many ...
0
votes
1answer
27 views

Unity: I need to edit my prefab but I can't move anything inside it!

I imported a character into Unity and turned him into a prefab. I couldn't get my custom "Look-At" script to work for the eyes, which are children of the prefab I imported. So I opened the prefab and ...
0
votes
0answers
14 views

Why doesn't the prefab change in the app?

Such a problem: from the script, I change the image of the sprite of SpriteRenderer component (like another skin) in a certain prefab, having a link to SpriteRenderer. And the problem is that when I ...
1
vote
1answer
99 views

If I don't use PrefabUtility class, how can I save my changed prefabs and build without exception?

I'm designing a racing game for my graduation project. I used PrefabUtility.SaveAsPrefabAsset to save my color change on the car prefabs, I finished the codes and it work well in Unity, but when I ...
0
votes
1answer
44 views

How to make collisions occur between objects using the same script?

Well what I’m trying to do is have cars travelling on the road. The cars have a trigger at the front and a hitbox at the back of the cars. What I want to happen is when the trigger hits the hitbox it ...
1
vote
1answer
693 views

Instantiating Prefabs at run time

I'm trying to move my project to Addressables and upload assets, prefabs and screens to an archive on the server. I'm a new in Unity and this a bit challenging for me. I've prepared all prefabs for ...
0
votes
1answer
39 views

How to store the configuration of Unity prefab components during map generation?

I managed to have a basic map generation algorhytm, but now it needs some content. I generate abstract map data, which then will be used to build the map itself. When I want to generate monsters, ...
1
vote
1answer
41 views

How can I insert a prefab instance programmatically inside the Canvas, in the bottom-left corner of the Canvas?

I am trying to create the Snake game in Unity, based on this video tutorial. I have also viewed this tutorial. I have created the new project with the 3D template and manually added the Canvas. I ...
0
votes
1answer
31 views

How to translate prefab made of hierarchy of 3d objects

I am trying to translate a prefab of a puzzle piece made of a hierarchy of cubes but it's not working. I have tried translating the GameObject using its transform and the function Translate, it did ...
0
votes
0answers
17 views

Perhaps all the settings that apply to prefab apply to terrain.terrainData settings?

I have a brush widget in which the following settings: Can I apply all these settings to terrain.terrainData? Common settings terrainData and ...
0
votes
1answer
20 views

Referencing Tilemap inside Grid Prefab

I have a prefab of a grid which contains 3 different tilemaps: Main, Foreground, & Background I want to reference the tilemaps inside a script of the prefab but can't figure out how to do that.....
0
votes
1answer
88 views

Can I add non-trees to terrain.terrainData.treeInstances on Unity 3D?

I need to create a brush in which there will be stones, poles, bushes and other elements of the environment. I bought a Prefab Brush. Whether it is possible to add the objects that I draw on the ...