THIS QUESTION IS NOT FINISHED!!
I need help guys. This is my problem. I want this enemy to die on collision of the bullet but I want the bullet to not sway when the bullet it being fired. This is what i have, a shooter object (has the code to shoot the projectile forward out), a projectile (the object being shot out of shooter), and a cube (the “enemy” that’s supposed to die when hit by the projectile). The code is use is basic, but yet it causes so much trouble.
This is the way i have the shooter
using UnityEngine;
using System.Collections;
public class ShootBullet: MonoBehavior {
public Rigidbody bullet;
public float power = 3000f;
public float spawnDistance = 1f;
public float delayTime 0f;
public float timeBetween = 20f;
public float delay = 1f;
void Update () {
if(Input.GetButton("Fire")) {
if (delayTime == 0) {
Rigidbody instance = Instantiate(bullet, transform.position + spawnDistance * transform.forward, transform.rotation) as Rigidbody;
instance.rigidbody.AddForce(instance.transform.forward * power);
}
}
}
THIS QUESTION IS NOT FINISHED!!