![alt text][1]
[1]: http://media.giphy.com/media/xTiTnf01urHLDwMz6w/giphy.gif
I need a trail of prefabs which shows the directory of the flight of my projectile.
Here's my code:
using UnityEngine;
using System.Collections;
public class bang : MonoBehaviour {
public Rigidbody rb;
public float jumpPressure;
public bool canshoot;
public bool canbomb;
public Transform door;
public GameObject booms;
public float timer;
// Use this for initialization
void Start () {
rb = GetComponent();
canshoot = false;
canbomb = false;
}
// Update is called once per frame
void Update () {
if (Input.GetButtonUp ("Fire1"))
{
rb.AddForce (transform.forward * jumpPressure * 2);
rb.AddForce (Vector3.up * jumpPressure);
canshoot = true;
canbomb = true;
}
if (timer > 0)
{
timer -= Time.deltaTime * 38f;
}
if (timer <= 0 && canbomb)
{
Instantiate (booms, door.position, Quaternion.identity);
timer = 2;
}
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag ("ground") && canshoot) {
rb.isKinematic = true;
canbomb = false;
}
}
}
As you can see I'm using a timer to determine the instantiation of my little spheres prefabs. I'm pretty happy with that, but how do set it so that there won't be any space between those little blue sphere? If make the timer too short, they start bumping into each other, and that's what I don't want.
***
Another question: can I somehow change the speed of the flight of my purple sphere?
I was trying to slow time -- but it looks more like a lag, that's not what I need.
Thanks!
↧