Skip to content

Instantly share code, notes, and snippets.

@takashiski
Created July 29, 2014 20:52
Show Gist options
  • Save takashiski/f9f826e4be9aa91a90fb to your computer and use it in GitHub Desktop.
Save takashiski/f9f826e4be9aa91a90fb to your computer and use it in GitHub Desktop.
よく使う適当に何か飛ばすスクリプト
using UnityEngine;
using System.Collections;
public class Gun : MonoBehaviour {
public GameObject bullet;
public float offset;
public float power;
public ForceMode mode;
public float lifetime;
void FixedUpdate () {
if(Input.GetButtonDown("Fire1"))
{
GameObject obj = Instantiate(bullet,offset*transform.forward+ transform.position,transform.rotation) as GameObject;
obj.rigidbody.AddForce(transform.forward*power, mode);
//Destroy(obj,lifetime);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment