Hey guys,
A few more Questions,
With the following code i want to modify the already existing gui text in the top corner, i have applied it to an object that when hits another should make the GUI counter go up by 1.
var Counter : int = 0;
function OnCollisionEnter (myCollision : Collision) {
if(myCollision.gameObject.name == "floor"){
Counter++;
guiText.text = "Score : " +Counter;
}
}
Another problem i have is a problem with instansiation, I have two diferent JS Scripts
1
var projectile : Rigidbody;
function Update () {
if(Input.GetButtonUp("Jump")){
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
}
}
2
var projectile : Rigidbody;
function Update() {
if(Input.GetButtonUp("Jump")){
rigidbody.AddForce(Vector3(0,0,250));
var clone : Rigidbody;
//clone = Instantiate(projectile, transform.position, transform.rotation);
}
if (Input.GetKey ("right")){
//rigidbody.AddForce(Vector3(15,0,0));
transform.Translate(Vector3(5,0,0) * Time.deltaTime);
}
if (Input.GetKey ("left")){
//rigidbody.AddForce(Vector3(0,15,0));
transform.Translate(Vector3(-5,0,0) * Time.deltaTime);
}
}
What i would like to happen is for the object to clone itself after the previous projectile has expired. what is currently happening is the projectile is being shot and cloned at the same time which is not what i want. Furthermore, the shot projectiles are also being controlled with the right and left arrow keys, I would only like the projectile that has not been shot to be controlled by the arrow keys. I can make a short youtube video if this helps explain the problem.
Thanks guys, you have already been a great help
.
Nick.