Textmesh material Alpha Lerp?

Hi everyone!

I’m trying to make my textmesh that is instantiated slowly move upwards and fade out over time. My code looks like this:

	function TextMove()
{
	var animationDuration : float = 2;
	var time : float = 0;
	var damper : float = 0.5;
	
	var startPosition : Vector3 = this.transform.position;
	var endPosition : Vector3 = Vector3(this.transform.position.x, (this.transform.position.y + 25),
	this.transform.position.z);
	
	while (time < animationDuration)
	{
		time += Time.deltaTime;
		transform.position = Vector3.Lerp(startPosition, endPosition, time * damper);
		this.gameObject.renderer.material.color.a = Mathf.Lerp(100, 0, time * damper);
		yield;
	}
	Destroy(this.gameObject);
}

the move just fine, but the alpha lerp doesn’t work at all. What am I doing wrong?

Thank you!

sure that the attached shader users / supports the alpha color component at all?

I am as sure as I can be, its the default font material that appears when you import a Font and it has an Alpha setting… so I hope it supports alpha :slight_smile:

Still can’t get it working, anyone know what I’m doing wrong?

Alpha is a fraction from 0 to 1, not a percentage. If you set it above 1, it essentially saturates to 1 and so you won’t see anything as the value decreases.

thanks andeeee (I had to count the e’s as I typed that haha :smile:)

so I want

Mathf.Lerp(1, 0, time * damper)

?

Yes, but i think trying it is faster than waiting for a forum post :stuck_out_tongue: