Attaching "Fire" button on iPad

Hi! 

I'm writing to ask a question about one of Unity prefabs I bought last week. It is called "3rd Person Cam Kit (iPhone)". I'm not very familiar with JavaScript and programming at all, so I have a problem with attaching iPad's buttons. I'm trying to attach shooting function to my character, and A1 button as firing button, which is set as "Jump" by default. I have already removed jump function, so my character is firing balls in play mode, when I press Space bar. But when I'm using Unity Remote on my iPad, it doesn't work. It actually did jump on both inputs before I removed jump function, but shooting is only working when I press Space... So which part of A1 button script should I put in my player's script? Here is my Player_PlayerRelative script.

Regards, Valdemars!

var groundSpeed : float; //Force applied when grounded

var airSpeed : float; //Force applied when in air

var jumpSpeed : float; //Force applied when jumping

var touchHorizontalRotationSpeed : float; //Horizontal rotation speed of the player when using touch-joystick

var mouseHorizontalRotationSpeed : float; //Horizontal rotation speed of the player when using the mouse

var onGroundDrag : float; //Rigidbody drag used on ground

var inAirDrag : float; //Rigidbody drag used in air

var keyboardMouseEnabled : boolean; //Is keyboard and mouse used for moving and rotating the player, useful for Editor testing

var movementJoystick : Joystick; //Joystick that controls the player movement

var rotationJoystick : Joystick; //Joystick that controls the camera pivot rotation

var bullitPrefab:Transform;

private var onGround : boolean = false; //Determines whether the player is grounded or in air

private var jump : boolean = false; //Determines whether the player should jump

private var rb : Rigidbody; //Reference to the rigidbody component of the game object

private var t : Transform; //Reference to the transform component of the game object

function Awake() { rb = rigidbody; //Cache rigidbody component t = transform; //Cache transform component gameObject.layer = 8; //Set gameObject layer to Player layer }

//Check for one-off input in the Update loop since checking for input in FixedUpdate can lead to lost input events function Update() { //Since we're not applying rotation as torque, we don't need to do it in FixedUpdate

if(rotationJoystick) { //If rotation joystick exists

rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * rotationJoystick.GetAxis().x * touchHorizontalRotationSpeed * Time.deltaTime)); //Rotate player using rotation joystick axis

} if(keyboardMouseEnabled) { //If keyboard and mouse are enabled rb.MoveRotation(rb.rotation * Quaternion.Euler(Vector3.up * Input.GetAxis("Mouse X") * mouseHorizontalRotationSpeed * Time.deltaTime)); //Rotate player using mouse axis } if(Input.GetKeyDown(KeyCode.Space)){ //If Space is hit and keyboard is enabled Jump(); }

if(Input.GetButtonDown("Jump")) //here is the part I want to activate with touching iPad's button

{ var bullit = Instantiate(bullitPrefab,GameObject.Find("spawnPoint").transform.position, Quaternion.identity);

bullit.rigidbody.AddForce(transform.forward * 2000);

}

} //Apply physics forces in FixedUpdate function FixedUpdate() { //Add force in the direction of movement var movement : Vector3; if(movementJoystick) { //If movement joystick exists movement = movementJoystick.GetAxis(); //Get movement joystick axis //Add force to player rigidbody using movement joystick axis rb.AddRelativeForce(movement.y * Vector3.forward * ((onGround) ? groundSpeed : airSpeed)); rb.AddRelativeForce(movement.x * Vector3.right * ((onGround) ? groundSpeed : airSpeed)); } if(keyboardMouseEnabled) { //If keyboard and mouse are enabled movement = Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0); //Get keyboard movement axis if(movement.sqrMagnitude > 1) movement.Normalize(); //Add force to player rigidbody using keyboard axis rb.AddRelativeForce(movement.y * Vector3.forward * ((onGround) ? groundSpeed : airSpeed)); rb.AddRelativeForce(movement.x * Vector3.right * ((onGround) ? groundSpeed : airSpeed)); } //if(jump) { //rb.AddForce(t.up * jumpSpeed); //Add upwards force to make player jump //onGround = false; //Player is no longer grounded //jump = false; //rb.drag = inAirDrag; //Change rigidbody drag to allow for better movement in air //} }

//If player is on ground, sets jump to true so player will jump when next FixedUpdate is called function Jump() { if(onGround) jump = true; }

//Check for collisions to determine when the player is on the ground function OnCollisionEnter(collision : Collision) { var collisionAngle = Vector3.Angle(collision.contacts[0].normal, Vector3.up); //Calculate angle between the up vector and the collision contact's normal if(collisionAngle < 40.0) { //If the angle difference is small enough, accept collision as hitting the ground onGround = true; //Player is grounded rb.drag = onGroundDrag; //Restore original drag value } }

function OnCollisionStay(collision : Collision) { var collisionAngle = Vector3.Angle(collision.contacts[0].normal, Vector3.up); //Calculate angle between the up vector and the collision contact's normal if(collisionAngle < 40.0) { //If the angle difference is small enough, accept collision as hitting the ground onGround = true; //Player is grounded rb.drag = onGroundDrag; //Restore original drag value } }

function OnCollisionExit (collision : Collision) { onGround = false; rb.drag = inAirDrag; }

Properly format your code!