- Home /
Question by
The_Dash_Dude · Aug 02, 2015 at 05:38 PM ·
instantiateprefabscalebulletboxcollider
When I instantiate a 2D bullet it's BoxCollider2D fails verification.
When my player shoots, the bullet created fails verification and won't collide with anything. The error message says this could happen under small scales, so I tried the bullet with a larger scale. It was at (0.2, 0.2, 0.2), and I changed it to (1, 1, 1). This didn't help. When I drag the prefab bullet into the scene it works fine, but when instantiated in-game it doesn't. Here is the code I used to create the bullet (the only code that deals with it so far):
if (Input.GetMouseButton (0) && canShoot) {
GameObject Shot = (GameObject) Instantiate(bullet);
Vector2 mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Shot.GetComponent<Transform>().position = GetComponent<Transform>().position;
Shot.GetComponent<Transform>().LookAt(mp);
Shot.GetComponent<Transform>().Rotate(90,0,0);
}
Any help would be appreciated.
Comment
Your answer
Follow this Question
Related Questions
Instantiating Cube Prefabs with scale 3 Answers
Get scale of instantiated prefab and resize 1 Answer
Instantiated prefab scale is wrong. 2 Answers
Instantiate prefabs scaled 1 Answer
Instantiating prefab of object like it was in the scene 0 Answers