->i coded this code for bullet and and to find the speed of the bullet while pressing the space bar before hitting the target and i displayed the speed of the bullet in gui text .
THE PROBLEM
→ I want to display the speed of the bullet in progress bar.so please help me to do this
using UnityEngine;
using System.Collections;
public class bulletsc : MonoBehaviour {
//public declarations zc
public Transform bullietPrefab;
//private declaration zc
private GameObject outGO=null;
private float force;
public GUIText forceshot;
void Start() {
//finding the gameobejct for instantiating zc
outGO = GameObject.Find("out");
//making the gui text to implement at the starting pistion zc
forceshot.text="forceShot=0";
}
void Update() {
if(Input.GetKey("space"))
{
force+=0.3f;
forceshot.text="forceShot="+force;
}
if (Input.GetKeyUp("space"))
{
Transform bulliet = Instantiate(bullietPrefab, outGO.transform.position, Quaternion.identity) as Transform;
bulliet.rigidbody.velocity=outGO.transform.TransformDirection(Vector3.forward*force);
force=0.0f;
}
}
}