trouble instantiating rocket from plane
My game has a number of instantiated projectiles...I lob arty shells, shoot bazooka rockets as well as shoot rockets from a moving boat ( medium to slow moving boat). But now I have a plane in my game and I can not get rockets to shoot like I was hoping. If I am on the ground it all works. But once I get some speed for take off or in the air the bullets fire backwards. I have cranked up the Dist to like 10000 and it may be working but it happens so fast I can't see it. The projectile is just a sphere with a rigidbody - not kinematic, no constraints, no gravity. They also behave weird when I do find that "perfect" velocity where I can actually see the rocket ( though barely traveling forward) it jitters all over the place as if it is still somehow connected to my plane. It isn't - at least not in the inspector, they are instantiating as separate gameObjects. Any answers for this one or work arounds so I can use my plane for battle and not just transportation??
GameObject myGrenade = Instantiate(grenade, Muzzle.position,transform.rotation)as GameObject;
myGrenade.GetComponent<Rigidbody>().AddForce (transform.forward *Dist);
Answer by Alex_May · Mar 25, 2019 at 10:57 PM
Are the bullets going backwards, or just a lot slower than the plane? Try to set the velocity of the bullets to the plane's velocity after you spawn them.
Also check the rockets are not set to collide with the plane in your collision matrix. They should be on different layers.
the bullets were going forwards. as my plane sped up I could see the gradual difference in forward thrust of the rocket as they went slower and shorter until,finally backwards. But I lowered the speed of my plane - although it seems to be an arbitrary number in that 60 for my plane doesn't seem any slower visually than 120. This seemed to fix everything getting rockets flying correctly. I also added a trail renderer to the rocket for .15f to give it a bit of a trail so I can see it and was able to knock off a lot of the speed for the rocket. Because of the lag I actually instantiate the rockets well below and ahead of my plane - or at least that is the spawn point but they appear to be co$$anonymous$$g out of the wings with the trail renderer and from the camera perspective. But thanks for the response. I don't get many
Your answer