Npc spawning outside the camera view and sliding down within the camera view
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
Your answer
Follow this Question
Related Questions
Error CS0201 when trying to change RigidbodyConstraints 1 Answer
Using Camera.main.ViewportToWorldPoint to limit player movement in the Y direction 0 Answers
How to make an object go the direction it is facing? 0 Answers
2D Player bounds problem based on moving camera 0 Answers
Rigidbody Based Third Person Controller Stutter Problem 0 Answers