Questions tagged [prefab]

92 questions
0
votes
2 answers

Material property change via code doesn't show

I'm using Unity 2020.3.3f1 (HDRP) I have a prefab (cube) which has a emissive material on it. After pressing the mouse button, I want it to increase its Emission intensity by 10. Problem that I encountered: The Inspector shows me that the Intensity…
Marko
  • 9
  • 1
  • 2
0
votes
1 answer

A* (Astar) Pathfinding doesn't work with Player Clone / Instantiate Unity

My player spawns at game play. when i put my Player Prefab into "target" then it doesn't follow. but when i put my clone(instance) of my prefab (what spawned in the hierachy when i start the game) into "target" then it works. how can i do that the…
Felaix
  • 5
  • 3
0
votes
1 answer

How to rotate multiple RigidBodies in a prefab based on user input

I'm currently trying to rotate different Rigidbodys in a prefab based on separate inputs. I have it working when each Rigidbody has a separate script attached to it with the designated input, but I need to combine them into one "master control"…
user17247507
0
votes
1 answer

How can I generate terrain rather than an object on drag and drop in Unity?

Background I would like to know how to write a code that a player can generate terrain by drag and drop in Unity3D version 2020.3. What I tried so far I can create terrain before execution for unchangeable background and land during the executing…
halt
  • 393
  • 5
  • 17
0
votes
2 answers

Prefab Instantiate performance improvment

so I have a multiple category buttons in every category there is more than 20 items. So make prefab and instantiate when button is pressed. The problem is When I instantiate prefab I have to initialize it with info like name, sprite, btn click event…
Jaimin
  • 501
  • 4
  • 13
0
votes
2 answers

C# Unity Prefabs wont show up on Canvas

My scene is 2D My Canvas is set to Screen Space - Overlay. (I don't want to change that) I can see my prefabs shoing up in the hierarchy but they're not visible. I bet it has something to do with the camera view, they're behind the camera or they're…
MindGem
  • 51
  • 1
  • 6
0
votes
3 answers

Unity : Destroy a GameObject that is part of a prefab

The console shows me this error : Cannot destroy GameObject that is part of a prefab instance. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) I'm confused. The Logs don't tell which prefab or GameObject is involved. Can u help me ? Thanks a…
0
votes
2 answers

How do I restrict one random prefab to be used only once but placed randomly with a whole bunch of prefabs of arrays on top of other object?

How do I restrict one random prefab to be used only once but placed randomly with a bunch of prefabs of arrays on top of other object? using System.Collections.Generic; using UnityEngine; public class LevelRoomsScript : MonoBehaviour { …
0
votes
1 answer

How do you get an int from a prefab?

I have a prefab of a store. This store has a count integer in it to signify how many things the store is holding. But this prefab populates many stores with different int values. So store one could have 3 items while store 2 has 40 items and so…
giff1
  • 101
  • 1
  • 12
0
votes
1 answer

Why more balls are instantiating?

I'm making a game in unity where the user drags to shoot a ball at some objects at a distance. So far I have this DragAndShoot script: //using System.Collections; //using System.Collections.Generic; using UnityEngine; …
physics35
  • 11
  • 1
0
votes
1 answer

Get velocity of instantiated prefab

I instantiate the Rigidbody "Clone" from my Prefab "Bullet" to shoot them in my project. I want to get the velocity of every bullet (every instantiation) I shoot. In the following my code example: public GameObject throwstart; public Rigidbody…
0
votes
1 answer

How to access methods after Instantiating a player prefab in GameManager?

I am fairly new to unity and am trying to make a game based on mapbox location based game. Right now I have an welcome scene where they choose a name and a character (male or female), which works perfectly fine and they chosen character shows on the…
Drogon
  • 360
  • 1
  • 4
  • 18
0
votes
1 answer

Spawn prefab randomly over polygon collider 2d in Unity

I have attached pollygon collider 2d on this gameObject. This gameObject is parent of another gameObject (just small circle). I want that small circle to randomly spawn somwhere on pollygon collider. I tried something like this: private void…
ludvik120
  • 49
  • 7
0
votes
1 answer

Dropdown options copying into other scene's dropdown - Unity3d

I am working on dynamically generating dropdown list options through the script, and based on the option value and with some conditions other scenes should load. (by clicking on the dropdown value new scene should load). I have attached the all…
sam
  • 127
  • 1
  • 5
0
votes
2 answers

Rigidbody 2D doesn't stop

In my scene I am instantiating at runtime a prefab, which has a dynamic Rigidbody2D and a BoxCollider2D; It also has a script with an OnTriggerEnter2D method, that runs the following function: /* ... */ public Rigidbody2D rigidbody; private void…
NicknEma
  • 414
  • 3
  • 13