- Home /
Question by
Dragon-Of-War · Dec 22, 2017 at 03:55 PM ·
unity 2d
Unity 2D: Instantiated objects are not visible
I'm starting a 2D shooter, and I'm trying to make my character shoot. I've made a script that instantiates a bullet when the player presses the arrow keys. Well, when I press the arrow keys, the bullets are instantiated, but for some reason, their not visible, neither in scene view, and neither in game view , even though the original bullet prefab being used is visible.
Here's the bullet that's being instantiated. As you can see, it's not visible, even though the sprite renderer is active and has a sprite.
And here's the method that is used to shoot the bullet.
protected void ShootBullet(Vector2 direction){
GameObject newBullet = Instantiate(bullet);
newBullet.transform.position = transform.position;
newBullet.transform.LookAt (direction);
newBullet.GetComponent<Bullet>().damage += charDamage;
newBullet.GetComponent<Bullet>().bulletSpeed += charShotSpeed;
}
captura-de-tela-10.png
(165.0 kB)
Comment
Best Answer
Answer by niocy · Dec 22, 2017 at 04:07 PM
Is it because you are using transform . Lookat? It might flip the bullet sideways.