void FixedUpdate() { if (rock) { if (caster != null) { //rb2d.isKinematic = true; if (!fire) { if (caster.faceRight) { direction.x = 1; } else { direction.x = -1; } float inputX = MultiInput.GetAxis("RightJoystickX", "", caster.name); float inputY = MultiInput.GetAxis("RightJoystickY", "", caster.name); Vector2 mag = new Vector2(inputX, inputY); if (mag.magnitude < 0.1f) { inputX = 0; inputY = 0; } float Xrock = (caster.transform.position.x + (1 * direction.x)) - this.transform.position.x + inputX; float Y = caster.transform.position.y - this.transform.position.y - inputY; if ((Xrock > 1.5 || Xrock < -1.5) || (Y > 0.1 || Y < -0.1)) { atCaster = false; Vector2 movement = new Vector2((speed.x) * Xrock, (speed.y) * Y); movement *= Time.deltaTime; rb2d.MovePosition(rb2d.position + (movement * 25) * Time.fixedDeltaTime); } else { hasShot = true; } } } // Weapon has been fired if (fire && speed.x >= 1) { gameObject.GetComponent <Rigidbody2D>().gravityScale = 0; hasShot = false; Vector2 movement = new Vector2(speed.x * direction.x * 1.5f, -(speed.y * direction.y * 3.0f)); speed.x = (speed.x - speed.x * 0.070f); speed.y = (speed.y - speed.y * 0.4f); movement *= Time.deltaTime; rb2d.MovePosition(rb2d.position + (movement * 50) * Time.fixedDeltaTime); //rb2d.AddForce((movement * 500)); // * Time.fixedDeltaTime); } else if (speed.x < 1) { caster = null; fire = false; connected = false; hasShot = false; caster = null; speed.x = 15; speed.y = 10; gameObject.GetComponent <Rigidbody2D>().gravityScale = 6; } } else { if (fire && !connected) { if (shotType.Equals("fire")) { animator.setAnimation("Fireball Shoot"); } if (shotType.Equals("plasma")) { animator.setAnimation("plasmaShoot"); } if (shotType.Equals("water")) { animator.setAnimation("waterShoot"); } if (shotType.Equals("air")) { if (animator.getAnimation().Equals("mostlyBlank")) { Destroy(gameObject); } //animator.setAnimation("airShoot"); airTime += Time.deltaTime; } hasShot = false; Vector2 movement = new Vector2(speed.x * direction.x, -(speed.y * direction.y)); //Debug.Log("" + direction.x); movement *= Time.deltaTime; rb2d.MovePosition(rb2d.position + (movement * 50) * Time.fixedDeltaTime); } } }