Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Disparo : MonoBehaviour
- {
- public Camera tankCam;
- float range = 100f;
- public GameObject bala;
- float force = 6000f;
- float expRad = 10000f;
- void Start()
- {
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- Shoot();
- }
- }
- void Shoot()
- {
- RaycastHit hit;
- if (Physics.Raycast(tankCam.transform.position, tankCam.transform.forward, out hit, range))
- {
- Instantiate(bala, hit.point, Quaternion.identity);
- }
- if (hit.rigidbody)
- {
- hit.rigidbody.AddExplosionForce(force, tankCam.transform.forward, expRad);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement