- Home /
Question by
Legostyle03 · Jul 28, 2020 at 10:35 PM ·
collisioninstantiatedetectionnoob
How to turn on detectcollision on instantiated objects?
For some reason cloned objects spawned from this script spawn without collision detection. How do i fix this? Script here:
IEnumerator AmmoDrop()
{
if (Ammocount < wavenumber)
{
xPos = Random.Range(37, 130);
zPos = Random.Range(0, 190);
yPos = Random.Range(1, 1);
Instantiate(Ammo, new Vector3(xPos, 2, zPos), Quaternion.identity);
yield return new WaitForSeconds(2);
xPos = Random.Range(-115, -20);
zPos = Random.Range(0, 190);
Instantiate(Ammo, new Vector3(xPos, 2, zPos), Quaternion.identity);
yield return new WaitForSeconds(2);
}
}
IEnumerator MediDrop()
{
if (Medicount < wavenumber/3)
{
xPos = Random.Range(37, 130);
zPos = Random.Range(0, 190);
Instantiate(Healthpack, new Vector3(xPos, 1, zPos), Quaternion.identity);
yield return new WaitForSeconds(2);
xPos = Random.Range(37, 130);
zPos = Random.Range(0, 190);
Instantiate(Healthpack, new Vector3(xPos, 1, zPos), Quaternion.identity);
yield return new WaitForSeconds(2);
}
}
Comment
Answer by deniskotpletnev · Jul 28, 2020 at 11:17 PM
This script just creates objects from prefabs. The problem most likely lies in the prefabs themselves. Are Colliders and Rigidbodies installed on them?
Your answer

Follow this Question
Related Questions
How to detect when an object goes past (so it looks like it touches) a UI element. 1 Answer
Detecting how much of a Sphere is overlapped 0 Answers
Raycast bullet impact and instantiating particles 3 Answers
Detect Side of Collision 2 Answers
How to detect when and where a particle hits a surface? 4 Answers