- Home /
Problem with 2D shooter Game?
**HI!
Im having a problem with my game im creating there are 2 major issues. ( Its a 2d/3d shootergame)
- When im shooting my rockets forward they are positioned sideways.(the model of the rocket is alined the wrong way, instead of pointing forward they are pointed to the left. How do I turn them to the right way?)
2 The second problem im having is that the rockets are being created from the top of the plane instead of starting from the wing?.**
This is the code im using.
var prefabRocket:Transform;
var shootForce: float;
function Update () {
if(Input.GetButtonDown("Jump")) { var instanceRocket = Instantiate(prefabRocket, GameObject.Find("fighter").transform.position, transform.rotation); instanceRocket.rigidbody.AddForce(transform.forward * shootForce);
}
}
Answer by qJake · May 13, 2010 at 09:12 PM
Your model has been oriented incorrectly in your 3D modeling program. Some modeling programs use the Y-up method, while some use the Z-up method, and this can throw off the export/import process, orienting your model wrong. (Unity uses the Y-up orientation method.) Simply rotate your rocket model in your modeling program until it's oriented correctly in Unity.
You should probably add a child GameObject to your ship, and then spawn the rockets from there. That way, you can control the exact position of where you want them to spawn. As of right now, your rockets will spawn at the origin of the ship's model, which you don't have a lot of control over. I find it useful to create a "Spawn Point" child object and attach it to whatever shoots the projectile, this way I can control the exact spawn position.