Thanks everyone for the help so far! Great community!.
My question this time is:
I have a bloodsplatter image and when I shoot my objects which are agaist a wall I want this blood splatter to appear directly behind them. I am using a firstperson shooter camera that can not move(I’m always looking at the wall). I want to fade as time goes on.
What is the best method to do this with? I read alot about GUITextures, Labels, Boxs, DrawTextures, materials and I feel overwealmed. I was hoping someone could tell me the best and easiest way to do this.
to make the texture fade I would find a way to modify the alpha and iirc alpha over a value of .5 is technically = .5 so you would have a variable that would constantly subtract from the alpha
var alpha : float = 1;
var fade : float = .1;
function Update()
{
alpha = (alpha - (fade * Time.deltaTime));
guiTexture.color = Vector4(.5,.5,.5,alpha);
}
create an empty object that is at 0,0,0 add a guitexture to it, add your picture file to guitexture
{TESTED SCRIPT} this script should fade the gui texture out over 10 seconds (5 secods normal 5 seconds fading away to nothing)
Have you looked at Projectors? I think drawing a projector onto the wall behind the object would be the most straightforward way of doing what you want to do here. Just make sure that it is set to only ‘shine’ onto the wall, by setting up layers.
sorry bout the misleading gui thing… anyways i got my code to work with a projector
var alpha : float = 5;
var color: float = 1; //use this to mod the color balance of the texture
var proj : Projector;
var fade : float = .1;
function FixedUpdate()
{
alpha = (alpha - (fade * Time.deltaTime)); //this causes the alpha value to decrease
proj.material.color = Vector4(color,color,color,alpha); //this sets the color ammount
// MAKE SURE THE MATERIAL YOU ARE USING IS Transparent/ Bumped diffuse
// the base color value of your texture may be off ie the color 1 may be dull or messed up when you first input it, just tweak the color value unitil it works
}
function Start ()
{
proj.nearClipPlane = 0.5;
}
that should just about do it read any notes i just listed in the code. also to setup a projector just create a new gameobject, Component-> rendering → projector. add a TRANSPARENT material to it and add the game object to the
“proj” variable. from there tweak what you need to to get the desired effect