hi, sorry for my english.
i have a gun on the left of screen. i can instantiate bullet end of its with Input.GetMouseButtonUp(0) and i destroy the bullet in 7 second. i want to move the clone bullets by left and right button. the problem is i dont know how to do that. i can move objects but clone objects doesnt affect.
here is my instantiate code attached to gun
#pragma strict
var readynow : boolean = true;
var gun : Transform;
public var bulletPrefab : Rigidbody;
public var gunEnd : Transform;
public var mouse_pos = Input.mousePosition;
function Update() {
if (Input.GetMouseButtonUp(0)) {
if(readynow){
Kopyala();
}
}
}
function Kopyala() {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
yield WaitForSeconds(0.1);
if (Physics.Raycast(ray, hit)) {
var bulletInstance : Rigidbody;
bulletInstance = Instantiate(bulletPrefab, gunEnd.position, gunEnd.rotation);
bulletInstance.transform.forward = gun.forward;
bulletInstance.rigidbody.AddForce(bulletInstance.transform.forward * 650);
}
}
and here is movement script attached bullet prefab
#pragma strict
function Start () {
}
function Update ()
{
{
Destroy(gameObject,7);
}
}
public function FixedUpdate ()
{
if(Input.GetButton("Fire1"))
{
rigidbody.AddForce (10, 20, 0);
}
if(Input.GetButton("Fire2"))
{
rigidbody.AddForce (-10, 20, 0);
}
}
as you can see i can add force clone bullets by mouse right and left clicks.
how convert mouse right and left buttons to UI buttons. please help
↧