hi all, i’m a videogame environment designer. i’m usign unity to create a personal dynamic scene.
but i have a proboblem with scripts.
i created a cube with physics and i made 1st person controller to collide with it. now i want that player can push the cube near a alpha plane nd, doing that, it performs following actions:
the alpha plane must hide
a panel containing project info must pop up
a light (pre-created by me) must turn on to enlight my 3D model.
can anyone show me the way to do that? maybe with a script.
I a while back created a street light that would detect the time of day, used a texture to simulate the ballast of the light. So it would flicker when coming on over half a second. When it was time to turn it off, I used another texture to simulate the quick drop off then a slight glow over 2 seconds.
When it was struck by a vehicle… ( mostly because I can’t drive) it would shut it’s self off for a quarter of a second and then turn it’s self back on.
Lastly, if the lamp was busted off of it’s base, the whole thing would turn it’s self off (as above) but with a shower of sparks…
Try this. Attach this script to the cube that hits the floor. Drag the light you want to activate into the myLight variable in the inspector. Uncheck the “enabled” box on the light (the script will take care of that). Hope this helps.
var myLight : Light;
function OnCollisionEnter(hit : Collision)
{
if (hit.gameObject.name == "freccia")
{
Destroy (hit.gameObject);
myLight.enabled = true;
}
}
or if you want to destroy an object other than the one that’s been hit.
function OnCollisionEnter ()
{
Destroy (GameObject.Find("freccia"));
myLight.enabled = true;
}
I haven’t had time to try this, but if your object is already in the scene, you just need to turn the renderer on and off just like the light. Try adding:
i tried it but seems to not work…anyway it goes well even without it…now i only have the problem to add some glow effect to cartello. it’s a FX reflective (glass) material but the text above looks transparent and cannot read on it, any suggestion to make the text inside glow?
I’ll work on it some more this evening. I thought I had this working, but perhaps not. Did you uncheck the renderer “enabled” box for cartello in the inspector? The script takes care of enabling it, but cartello should be invisible at first.
As for the glow, I’m not very good with shaders etc. Hopefully one of the more artistic people will help out here. There are self-illuminating shaders available in standard assets, but I haven’t tried them for text or even know if that would work. I’ll give it a try when I have a moment later today.
By the way, looked at your website. The game looks nice so far