Bullets are created on fire input with a rigidbody and an “AddForce”. The ship is animated along a course via the new Timeline editor. But when the player shoots, the bullets aren’t moving “with” the ship. I can speed them up to sort of “catch up” and take the ship over but It looks wrong and the bullets end up moving crazy fast.
Standing still the bullets work great, shooting out and away from the front of the ship. But moving, the animation is just too fast for the instantiated bullets and they don’t count for how fast the ship is currently moving.
I also have other ship weapons that have fun stuff like shell casings that just vanish out of view because they can’t keep up and I don’t want them to shoot away like bullets by adding force to them. They need to be more lazy and slowly arc towards and away from the camera attached to the player.
![
][1]
In the image, the bullets are behind the ship when they should be coming out of the front and moving away from the ship, even while the ship moves along it’s animated rail via the Timeline.
From what I understand, rigid bodies on the ship/children have a velocity of zero because the animation overwrites physics. so isntant.rigidbody.vellocity = ship.rigidbody.velocity has no effect…
Is there a way to child the bullets through the hierarchy so that they move normally (in front of the ship) instead of lag behind? So, as an example, the ship would have a child empty object where the bullets would nestle under as soon as they come into existence. That way the parent’s motion would count towards the force and power of the prefab child bullet/shell casing/whatever I want to throw under it…
anyone have any suggestions on how to get this to work?
my bullet scripts are in two places.
First is the player input controller for instantiation:
Instantiate(bulletPrefab, bulletSpawner.transform.position, Quaternion.identity);
and
bullet prefab itself:
public float shootPower = 5000f;
public Rigidbody rb;
public Rigidbody spawnerRb;
public GameObject bulletSpawnPoint;
public GameObject particlePretty;
void Start () {
bulletSpawnPoint = GameObject.Find("Bullet Spawn 1");
spawnerRb = bulletSpawnPoint.GetComponent<Rigidbody>();
rb = this.GetComponent<Rigidbody>();
rb.velocity = spawnerRb.velocity;
rb.AddRelativeForce(bulletSpawnPoint.transform.forward * shootPower);
…
//and then the rest is die after x seconds function as well as a particle spawn on colliison