Quantcast
Channel: Latest Questions by theawesome
Viewing all articles
Browse latest Browse all 4

Help with AI patrol

$
0
0
Help!!! I've made a script which sends the enemy one way, but I can't figure out how to make him go back, and repeat!!!! Here's the script : can you try to tell me what to do? using UnityEngine; using System.Collections; public class SimpleEnemyScripy : MonoBehaviour { public float velocity = 1f; public Transform sightStart; public Transform sightEnd; public LayerMask detectWhat; public bool colliding; // Use this for initialization void Start () { } // Update is called once per frame void Update () { rigidbody2D.velocity = new Vector2 (velocity, rigidbody2D.velocity.y); colliding = Physics2D.Linecast (sightStart.position, sightEnd.position, detectWhat); if (colliding) { transform.localScale = new Vector2 (transform.localScale.x * -1, transform.localScale.y); velocity*= -1; } } void OnDrawGizmos() { Gizmos.color = Color.magenta; Gizmos.DrawLine (sightStart.position, sightEnd.position); } } thanks!!!

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images