I have to shoot 2 different targets.I can choose which one to shoot but i want to do it directly by just pushing button “1” for the fisrt or “2” for the other and then just click to shoot.
var Force:int = 250;
var prefabshoot:Transform;
var target:Transform;
var minDistance:int;
function Update () {
pivotPoint = gameObject.transform.position;
pivotPoint = rotateArrow.pivotPoint;
spawnPoint = pivotPoint + Vector3(0, 5, 0);
shootDirection = target.position - spawnPoint;
shootDistance = Vector3.Distance(target.position, spawnPoint);
if(Input.GetMouseButtonDown(1)) {
if (shootDistance < minDistance ) {
var instantiatedBall = Instantiate(prefabshoot, spawnPoint , Quaternion.identity);
instantiatedBall.rigidbody.AddForce(shootDirection* Force);
}
}
}
How can i put the different targets in here ? (i’ve made them as character controllers)