GameBuilders CommunityLog in

GameBuilders - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptionEasy Gun Script

Just attach this to the gun

using UnityEngine;
using System.Collections;

public class Instatinate : MonoBehaviour {

// Use this for initialization
public Rigidbody bullet;
public Transform emptygameobject;
public float distance;
public GameObject enemy;

void Start () {


// Update is called once per frame

void Update () {
if (Input.GetButtonDown ("Fire1")) {

Rigidbody rocketInstance;
rocketInstance = Instantiate(bullet, emptygameobject.position, emptygameobject.rotation)as Rigidbody;
rocketInstance.AddForce(emptygameobject.forward * 5000);

void myRaycast(){
RaycastHit hit;
Ray myRay = new Ray(transform.position, Vector3.forward);
if(Physics.Raycast (myRay, out hit, distance)){
if(hit.collider.tag == "enemy"){



descriptionRe: Easy Gun Script

thanks helps alot cheers

descriptionRe: Easy Gun Script

ummm so i want to use this but im not sure if i need to get a bullet asset since im new so please help me!
Permissions in this forum:
You cannot reply to topics in this forum