Advertisement
tonynogo

Demo 97 - Apply player position

Aug 5th, 2017
7,665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. public class ApplyPlayerPos : MonoBehaviour
  2. {
  3.     Material Mat;
  4.     GameObject Player;
  5.     public int Radius = 10;
  6.  
  7.     void Start()
  8.     {
  9.         // Get the material
  10.         Mat = GetComponent<Renderer>().material;
  11.         // Get the player object
  12.         Player = GameObject.Find("Player");
  13.     }
  14.  
  15.     void Update()
  16.     {
  17.         // Set the player position in the shader file
  18.         Mat.SetVector("_PlayerPos", Player.transform.position);
  19.         // Set the distance or radius
  20.         Mat.SetFloat("_Dist", Radius);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement