-
Notifications
You must be signed in to change notification settings - Fork 0
/
BallShooter.cs
33 lines (28 loc) · 901 Bytes
/
BallShooter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using HoloToolkit.Unity;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallShooter : Singleton<BallShooter>
{
public Rigidbody ball;
public float fireRate = 3.0f;
private float nextFire = 0.0f;
public float velocity = 5.0f;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Rigidbody clone = (Rigidbody)Instantiate(ball, transform.position, transform.rotation);
//clone.velocity = transform.forward * 10f;
clone.velocity = new Vector3(Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f) * velocity;
clone.position = new Vector3(0.0f, 0.0f, 1.0f);
clone.tag = "Target";
Destroy(clone.gameObject, 30);
}
}
}