I have made an Alien Object that will turn once it hit a solid wall (With the script below), and I’ve made a material for lightening effects, however the alien turns black inside the game once it hits the wall.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookForward : MonoBehaviour {
public Transform sightStart, sightEnd;
public bool needsCollision = false;
private bool collision;
private Vector2 localscale;
// Use this for initialization
void Start () {
localscale = new Vector3 (1, 1, 1);
}
// Update is called once per frame
void Update () {
collision = Physics2D.Linecast(sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("Solid"));
Debug.DrawLine (sightStart.position, sightEnd.position, Color.green);
if (collision == needsCollision) {
localscale = new Vector3 (transform.localScale.x == 1 ? -1 : 1, transform.localScale.y, transform.localScale.z);
transform.localScale = localscale;
}
}