- Home /
terrain tree children problem
i have a bunch of trigger sphere colliders set up as a child of the tree renderer. When i painted them onto the terrain the trigger colliders dont do what the script on them is telling them to do. I dont know if they re even there. Please help im really confused.
EDIT : This script is part of a dynamic fire pack. An editor script it comes with generates like 400 sphere collider each with the script below on it. When the fire object comes in contact with a collider it instantiates another fireobject. I dont think the children colliders are there when its parent tree is painted on the terrain.
#pragma strict
var fireParticle : Transform;
var firePoints : Transform[]; //Fire particles will be created at these positions once alight.
var fuel : float = 100.0; //The amount of fuel stored in this object. Fuel will burn out over time.
var fuelConsumption : float = 30.0; //The amount of fuel consumed per second by the object.
var fireSpread : float = 2.0; //The radius at which fire will spread
var spreadTime : float = 3.0; //The time after which fire will spread
var randomRange : float = 1.2; //The random maximum time after the spreadTime
var fallOutC : float = .05; //The chance that a Fire Point will fall out after some burn time
private var fireStarted : boolean = false;
private var fireC : Transform[];
private var count : int = 0;
private var fTime : short = 0.0;
private var fSpread : boolean = false;
private var fellOut : boolean = false;
private var bColor : boolean = false;
private var spPos : Vector3 = Vector3.zero;
function Update ()
{
if (fireStarted)
{
fuel -= fuelConsumption * Time.deltaTime;
if ((Time.time - fTime) >= spreadTime && !fSpread)
{
spreadFire();
if (Random.value > .95 && transform.root && transform.root.renderer && !bColor)
bColor = true;
}
if (!fellOut)
{
if (Random.value > 1-fallOutC)
fallOut();
fellOut = true;
}
}
if (fuel <= 0 && fireStarted)
endFire();
if (bColor)
{
var CL : Color = transform.root.renderer.material.color;
CL.r -= .01 * Time.deltaTime;
if (CL.r < .1)
{
CL.r = .1;
bColor = false;
}
CL.g = CL.r;
CL.b = CL.r;
transform.root.renderer.material.color = CL;
}
}
function startFire()
{
if (!fireStarted)
{
fireStarted = true;
for (var all : Transform in firePoints)
{
var fire = Instantiate(fireParticle, all.position, Quaternion.identity);
fire.parent = transform;
fireC[count] = fire;
count++;
}
fTime = Time.time;
}
}
function endFire()
{
for (var all2 : Transform in fireC)
{
if (all2.particleEmitter)
all2.particleEmitter.emit = false;
for (var child : Transform in all2)
if (child.particleEmitter)
child.particleEmitter.emit = false;
}
fireStarted = false;
for (var all3 : Transform in firePoints)
Destroy(all3.gameObject, 5);
Destroy(this);
}
function Awake()
{
fireC = new Transform[firePoints.length];
setWind();
}
function spreadFire()
{
fSpread = true;
var InRange = Physics.OverlapSphere(spPos, fireSpread);
for (var all : Collider in InRange)
{
yield WaitForSeconds(Random.value * randomRange);
if (all.GetComponent("FirePoint"))
all.SendMessage("startFire");
}
}
function fallOut()
{
transform.parent = null;
rigidbody.useGravity = true;
}
function setWind()
{
yield WaitForSeconds(.1);
switch (WindControl.windV)
{
case 0 : spPos = transform.position; break;
case 1 : spPos = transform.position + Vector3(0, 0, fireSpread-(fireSpread/(1+(2 * (WindControl.windS+0.001))))); break;
case 2 : spPos = transform.position - Vector3(fireSpread-(fireSpread/(1+(2 * (WindControl.windS+0.001)))), 0, 0); break;
case 3 : spPos = transform.position + Vector3(fireSpread-(fireSpread/(1+(2 * (WindControl.windS+0.001)))), 0, 0); break;
case 4 : spPos = transform.position - Vector3(0, 0, fireSpread-(fireSpread/(1+(2 * (WindControl.windS+0.001))))); break;
}
}
ive updated my post but if anyone has a script for placing gameObjects at the location of tree prototypes??
Your answer
Follow this Question
Related Questions
Unity 4 - Sphere Falls through Terrain 2 Answers
Getting treePrototype information from RayCasting collisions onto terrain? 2 Answers
Terrain Tag OnControllerColliderHit not showing 0 Answers
Bucket with apples on a terrain (Sphere Colliders + Mesh Collider + Terrain) 0 Answers
How can I separate tree colliders from terrain colliders? 2 Answers