Neon color and movement code


Here are the result of my

To obtain the neon color for the pawns and the paths:

Source: https://www.youtube.com/watch?v=_E6NbLucJ2Y

Code Glow shader: https://pastebin.com/YnXiGQBs

In unity, we have to create a new shader and to paste this code in it:

Shader "Glow" {
   Properties {
       _MainTex ("Texture", 2D) = "white" {}
       _Color ("Color", Color) = (1,1,1,1)
       _Glow ("Intensity", Range(0, 3)) = 1
   }
   SubShader {
       Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
       LOD 100
       Cull Off
       ZWrite On
       Blend SrcAlpha OneMinusSrcAlpha

       Pass {
           CGPROGRAM
               #pragma vertex vert
               #pragma fragment frag

               sampler2D _MainTex;
               half4 _MainTex_ST;
               fixed4 _Color;
               half _Glow;

               struct vertIn {
                   float4 pos : POSITION;
                   half2 tex : TEXCOORD0;
               };

               struct v2f {
                   float4 pos : SV_POSITION;
                   half2 tex : TEXCOORD0;
               };

               v2f vert (vertIn v) {
                   v2f o;
                   o.pos = mul(UNITY_MATRIX_MVP, v.pos);
                   o.tex = v.tex * _MainTex_ST.xy + _MainTex_ST.zw;
                   return o;
               }

               fixed4 frag (v2f f) : SV_Target {
                   fixed4 col = tex2D(_MainTex, f.tex);
                   col *= _Color;
                   col *= _Glow;
                   return col;
               }
           ENDCG
       }
   }
}

Here is the code for moving for the ball (pawns):

Rigidbody rb;

void Start () {

rb = GetComponent<Rigidbody>();
}

void Update () {
if(Input.GetKey(KeyCode.UpArrow)){
rb.AddForce(Vector3.left*BallAmt);
}

if(Input.GetKey(KeyCode.DownArrow)){
rb.AddForce(Vector3.right*BallAmt);
}

if(Input.GetKey(KeyCode.LeftArrow)){
rb.AddForce(Vector3.back*BallAmt);
}

if(Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(Vector3.forward*BallAmt);
}

In this code, the ball is moved by the left, right, up and down arrows but in the game, it will adapted to A, W, S and D.

Get Neon Pathways

Leave a comment

Log in with itch.io to leave a comment.