public void Shoot() { if (cannon != null) { cannon.Shoot(); } }
// Update is called once per frame void Update() { animator.SetFloat("Speed", rigidbody.velocity.magnitude); Vector3 dir; dir.x = Input.GetAxis("Horizontal"); dir.y = 0; dir.z = Input.GetAxis("Vertical"); rigidbody.velocity = dir * 5f; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, float.MaxValue)) { Vector3 dirToCursor = hit.point - transform.position; dirToCursor.y = 0; transform.forward = dirToCursor; if (Input.GetButtonDown("Fire1")) { dirToCursor.y = transform.position.y; shootComponent.Shoot(transform.position, dirToCursor); particleSystem.Play(); } } }
private void Shoot() { ShootComponent shootComponent = (ShootComponent)weaponInventory.weapons[index].components.Find(BaseComponent => BaseComponent.GetType() == typeof(ShootComponent)); if (shootComponent != null) { Vector3 barrelPosition = weaponInventory.weapons[index].barrelPosition; Vector3 projectilePosition = weaponHolder.TransformPoint(barrelPosition); shootComponent.Shoot(projectilePosition, weaponTransform.rotation); } }
public void Shoot(float angleOffset = 0) { Vector3 diff = targetTransform.position - transform.position; if (diff.magnitude > shootRange) { return; } Vector3 direction = diff.normalized; shootComponent.Shoot(direction, angleOffset); }
void InputCntrl_Space() { ShootComp.Shoot(); }
public void Shoot() { _shootComp.Shoot(); }