- Home /
Question by
BrentHeynsmans · Nov 27, 2014 at 03:57 PM ·
c#gameenemy
How to make enemy speed up
I made a gravity runner game but I want the enemy to speed up in the beginning because he starts outside of the screen, any suggestions? Here is my code:
using UnityEngine;
using System.Collections;
public class Enemy : MonoBehaviour {
public Transform target;
public int MoveSpeed = 8;
public int MaxDist = 2;
public int MinDist = 1;
private Zwaartekracht vijand;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.LookAt(target);
if(Vector3.Distance(transform.position,target.position) >= MinDist && Zwaartekracht.state == 1){
transform.position += transform.forward * MoveSpeed * Time.deltaTime;
/*if(Vector3.Distance(transform.position,target.position) <= MaxDist)
{
//Here Call any function U want Like Shoot at here or something
} */
}
}
}
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Only one of all my Enemies shoots, Help please. 1 Answer
Unity error CS1014 1 Answer
Collision not happening 1 Answer