1
Support / Re: Rotating sprites
« on: May 30, 2013, 04:38:46 pm »
I should probably start looking for the simplest solutions first 
Thanks a lot, you've been of great help!

Thanks a lot, you've been of great help!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

if (targetPoint.x > transform.position.x)
{
Vector3 direction = targetPoint - transform.position;
transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg);
}
else if (targetPoint.x < transform.position.x)
{
Vector3 direction = transform.position - targetPoint;
transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg);
} Quaternion rotation = Quaternion.LookRotation((m_NextNode.m_Position - transform.position).normalized, transform.up);
Vector3 tempRot = rotation.eulerAngles;
tempRot.y -= 90f;
tempRot.z *= -1f;
transform.rotation = Quaternion.Euler(tempRot);

void SetSaturation(float saturation)
{
texture2D = animSpriteTexture;
Color[] pixels = texture2D.GetPixels();
for (int i = 0; i < pixels.Length; i++)
{
HSVColor temp = HSVColor.FromColor(pixels[i]);
temp.s = saturation;
pixels[i] = temp.ToColor();
}
texture2D.SetPixels(pixels);
texture2D.Apply ();
}
Shader "Custom/DiffuseDetailCuttoff"
{
Properties
{
_DiseaseColor ("Disease Color", Color) = (1,1,1,1)
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_DetailTex ("Detail Texture", 2D) = "white" {}
_DetailFade ("Defail Fade", Range(0, 1)) = 1.0
_DetailTiling ("Detail Tiling", Float) = 1.0
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha
LOD 110
Pass
{
CGPROGRAM
#pragma vertex vert_vct
#pragma fragment frag_mult
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
sampler2D _MainTex;
half4 _MainTex_ST;
sampler2D _DetailTex;
fixed4 _DiseaseColor;
fixed4 _Color;
half _DetailTiling;
fixed _DetailFade;
struct vin_vct
{
half4 vertex : POSITION;
half4 color : COLOR;
fixed2 texcoord : TEXCOORD0;
};
struct v2f_vct
{
half4 vertex : POSITION;
fixed4 color : COLOR;
fixed2 texcoord : TEXCOORD0;
};
v2f_vct vert_vct(vin_vct v)
{
v2f_vct o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.texcoord = v.texcoord;
return o;
}
fixed4 frag_mult(v2f_vct i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
fixed4 det = tex2D(_DetailTex, i.texcoord * _DetailTiling);
fixed3 minusDet = 1 - det;
col *= _Color;
col.rgb += lerp(det.rgb * _DiseaseColor.rgb, (0,0,0), _DetailFade);
return col;
}
ENDCG
}
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off Blend SrcAlpha OneMinusSrcAlpha Cull Off Fog { Mode Off }
LOD 100
BindChannels
{
Bind "Vertex", vertex
Bind "TexCoord", texcoord
Bind "Color", color
}
Pass
{
Lighting Off
SetTexture [_MainTex] { combine texture * primary }
}
}
}