- Home /
Need help with shooting script
Can someone please help me with this shooting script i am working on? I have no idea what i am doing. :(
using UnityEngine;
using System.Collections;
public class Bullet : MonoBehaviour
{
var Fire;
// Use this for initialization
void Start ()
{
var Fire = false;
}
// Update is called once per frame
void Update ()
{
if (GetMouseDown = true);
{
var Fire = true
}
if (Fire = true);
{
Spawn object laser
}
}
}
I have no idea what you're doing either. Be more specific please. What exactly do you want?
Answer by Spider-og · Feb 06, 2013 at 04:38 AM
using UnityEngine; using System.Collections;
public class example : MonoBehaviour {
public Rigidbody projectile;
void Update() {
if (Input.GetButtonDown("Fire1")) {
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
}
}
Answer by justinl · Sep 21, 2012 at 02:38 PM
I don't know what you want because your question was so vague, but here's a great tutorial on how to create a gun in Unity. The code formatting is horrendous but you'll get the idea
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Bullets sometimes shoot under map 1 Answer
Shooting speed help! 1 Answer
Help with a Script in C# for shooting and lighting 1 Answer
Shoot Script Help 1 Answer