-
-
Save takashiski/f9f826e4be9aa91a90fb to your computer and use it in GitHub Desktop.
よく使う適当に何か飛ばすスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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