Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ShootingProjectileScript : MonoBehaviour {
- public GameObject muzzle;
- public Rigidbody projectile;
- public float speed;
- public Vector3 muzzlePos;
- public Vector3 projectilePos;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- muzzlePos = transform.position;
- if (Input.GetMouseButtonDown(0))
- {
- Rigidbody clone;
- clone = Instantiate(projectile, muzzlePos, transform.rotation) as Rigidbody;
- clone.velocity = transform.TransformDirection(Vector3.forward * 10);
- Object.Destroy(projectile, 2.0f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement