- Home /
Npc Movement
Hi, I am trying to create an Npc that will move left and right continuously. All that works, but when its spawned, it will just pop up instead of sliding down from out the the camera view. thank you.
public class NPCMovement : MonoBehaviour {
public float tmp = 1f;
public float npcspeed =1f;
public float DMG;
public float iDmg;
public Vector3 startposition;
private RandomHazzards randomHazzards;
// Update is called once per frame
void Update () {
Vector3 q = startposition;
q.x += tmp * Mathf.Sin (Time.time* npcspeed);
transform.position = q;
if (GameObject.FindGameObjectWithTag("Player") == null)
{
Destroy(gameObject);
}
}
Comment