using UnityEngine;
using System.Collections;
public class Bullet : MonoBehaviour
{
public int moveSpeed = 220;
public Transform explosionPrefab;
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.right * Time.deltaTime * moveSpeed);
Destroy(gameObject, 1);
}
void OnCollisionEnter(Collision collision)
{
ContactPoint contact = collision.contacts[0];
Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
Vector3 pos = contact.point;
Instantiate(explosionPrefab, pos, rot);
Destroy(gameObject);
}
}
Been at it for a couple days. Really can't figure this one out for some reason.
↧