Last active
April 7, 2017 09:31
-
-
Save yjsoon/d5d068bbe55b0843bad2006a12e4e9a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BallGeneratorScript : MonoBehaviour { | |
public Rigidbody ballTemplate; | |
public float ballSpeedX = 200.0f; | |
public float ballSpeedY = -100.0f; | |
public float startTime = 0.0f; | |
public float timeInterval = 5.0f; | |
// Use this for initialization | |
void Start () { | |
InvokeRepeating ("GenerateBall", startTime, timeInterval); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
void GenerateBall() { | |
Vector3 pos = transform.position; | |
Quaternion rot = transform.rotation; | |
Rigidbody generatedBall = (Rigidbody)Instantiate (ballTemplate, pos, rot); | |
generatedBall.AddForce (new Vector3 (ballSpeedX, ballSpeedY, 0)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment