Have object fly towards camera
I need help developing a script in which objects fly towards camera and are destroyed once outside viewport. I'm creating a space scene in which meteors fly towards the camera in Z space and camera doesn't move. So the script would initialize an object (Meteor) at a certain distance the object flies towards the screen in Z space flies just past the camera and disappears. Im fairly new to scripting and unity and have been working with this script from another project which rotates the object but not really what I want.
using UnityEngine;
using System.Collections;
public class RandomRote : MonoBehaviour {
private Vector3 rotationSpeed;
// Use this for initialization
void Start () {
rotationSpeed = new Vector3(Random.Range(5,15),Random.Range(5,15),Random.Range(5,15));
}
// Update is called once per frame
void Update () {
transform.Rotate( rotationSpeed * Time.deltaTime);
}
}
Your answer
Follow this Question
Related Questions
RogueLike 2D (Tutorial) Rotation of Player 1 Answer
Help: Use a Trigger object to slow Player while inside object 0 Answers
I can't move my player in a fps? 1 Answer
Need help to solve problems with First Person Dungeon Crawler movement script 0 Answers
Regarding transform.position in the roll a ball tutorial 0 Answers