iTween.CameraFade

Anyone know the difference between

iTween.CameraFadeFrom(0.0, 1.0);

and

iTween.CameraFadeTo(1.0, 1.0);

Thanks
AC

The “From” methods in iTween will animate from the supplied value to whatever the current value is.

The “To” methods in iTween will animate from the current value to the supplied value.

Hope that helps.

Hi there,

CameraFadeTo is working really well but after the fade is complete I’d like to LoadLevel. I’ve been reading the docs and attempting the Hashtable techniques without success. I’m using JS.

Thanks

Jeff

Along these lines Jeff
[code/]

function OpenPortal()
{

//print(“OpeningPortal”);
iTween.CameraFadeAdd(GUI_Black,10);

//fadeToblack
iTween.CameraFadeTo(1.0, 1.0);

yield WaitForSeconds(1);

CompleteGUI.active=true;

Application.LoadLevel(nextLevel);
Destroy(this);
}

[/code]

Great, that’s working well now.

How about a fade in at the start of the scene:

function fadein(){

	iTween.CameraFadeAdd(cameraTexture,200);
	iTween.CameraFadeFrom(1,0);
	iTween.CameraFadeTo(0,2);
		
}

The code above seems to loop, fade in then black, then fade in then black. I’ve tried in the Start function so I can’t see why it would be looping.

You dont need the third line Jeff- either of those second two execute a behaviour, so you’re kinda doubling up.

try one alone, then the other. Not sure of the looping

Aaron

So strange, I’ve tried every combination without success.

I think the issue is that the scene loads with full visibility so I need to somehow quickly set it to black and then fade in. That’s what I was trying to do with my initial example.

Sounds like you need to have a GUITexture in the scene physically, so you can set it up from the outset. Try a basic black gui with an animation component on it, fading? Give us an email if you need me to send an example.
Aaron

Yeah making some progress but not perfect yet. I now have the level fading in the first time but after using a LoadLevel it flashes from visible to black and then fades in.

pixelplacement1 - What would be wonderful is an example where a scene fades in from black, then a button click fades the scene to black and uses LoadLevel to reload the same scene which should then fade back in from black.

Would that be possible?

Thanks

Jeff

Yup!

void Start ()
{
	//Make a default black color fade 
	iTween.CameraFadeAdd();
	
	//Fade from black:
	iTween.CameraFadeFrom(iTween.Hash("amount",.5));
	
	//Fade to black and reload after 5 seconds (we need to provide an "onCompleteTarget" as the CameraFade is carrying out the iTween but the "Reload" method in on this GameObject):
		iTween.CameraFadeTo(iTween.Hash("amount",.5,"delay",4,"onComplete","Reload","onCompleteTarget",gameObject));
}

void Reload(){
	Application.LoadLevel("scene");
}

Hey thanks for this - testing now.

I’ll be using this in a Javsscript, if there are any Javascript differences which are not obvious please let me know.

I’m first testing your C Script and received this error:

Assets/NewBehaviourScript.cs(10,16): error CS1501: No overload for method CameraFadeAdd' takes 0’ arguments

Sorry if there is an obvious fix but I wanted to show you the error I received when running the code above.

Cheers

Jeff

What version of iTween are you using (looks like not the most recent)? I changed the camera stuff a few versions back.

I’m using version 2.0.13 - the version included in the examples I purchased.

If your still stuck Jeff send me a small sample file and I’ll take look
Aaron

Upgrade to .34 and let me know how it goes. I don’t keep the version of iTween up-to-date in the examples (as it says on the examples page).

I hope this upgrade helps!

Let me know.

This is my first go at using iTween. I am using it in conjunction with iTween Path Editor and the iTween visual editor. Fantastic stuff!

I would like to be able to just fade up the camera over a time of 4 seconds. Using your code above, I do get a fade up but no matter what value I enter for amount - I always a very quick fade up. Am I doing something wrong?

Using JavaScript:

function Start ()
{
	//Make a default black color fade 
	iTween.CameraFadeAdd();
	
	//Fade from black:
	iTween.CameraFadeFrom(iTween.Hash("amount",4.0));
}

Also - how would I use a easetype in this scenario?

And, one last question - can a camera fade in be done by just using the iTween visual editor?

Thanks for any help.

Mitch

You could leave the camera as is and instead, put a “plane” in front of your camera, and just have that plane “fade to”- || alpha 0- || time 2 -|| delay 2…as example values… hope this helps, it works like a charm for my level fade ins’ and fade outs.

Ingenious - works like a charm with a transparent shader and easetype of easeInOutSine. Thanks for the fantastic suggestion.

Out of curiosity, I would still like to know how to work this out with the camera either by coding in iTween or using the iTween visual editor. Any thoughts anyone?

Mitch