26 lines
778 B
C#
Executable File
26 lines
778 B
C#
Executable File
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class testGunBullet : MonoBehaviour
|
|
{
|
|
|
|
public Rigidbody rb;
|
|
Camera camera;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
Rigidbody rb = GetComponent<Rigidbody>();
|
|
Camera camera = FindAnyObjectByType<Camera>();
|
|
Ray ray = camera.ScreenPointToRay(Input.mousePosition); // i hate this
|
|
//Transform cameraTransform = Camera.main.transform;
|
|
Vector3 cameraPos = camera.transform.forward;
|
|
rb.AddForce(cameraPos * 500000 * Time.deltaTime);
|
|
StartCoroutine(SelfDestruct());
|
|
}
|
|
|
|
IEnumerator SelfDestruct() {
|
|
yield return new WaitForSeconds(1f);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|