Answer the question
In order to leave comments, you need to log in
Why does the corner disappear when creating an object from a prefab?
Hello everyone
I'm creating an object from a prefab. In the prefab, the object has an angle (0, 90, 0 for example). After creation, the object gets an angle that is different from the prefab. Why and how to correct the behavior (so that the angle of the prefab and the angle of the new object match)
WeaponItem currentWeapon = WeaponsInventary.instance.GetCurrentWeapon();
GameObject shootingPoint = Utils.FindObjectByTag(gameObject, shootingPointTag);
Debug.Log(currentWeapon.bullet.transform.rotation);
Debug.Log(currentWeapon.bullet.transform.localRotation);
GameObject bullet = Instantiate(currentWeapon.bullet,
shootingPoint.transform.position, Quaternion.identity);
bullet.transform.localRotation = Quaternion.Euler(currentWeapon.bullet.transform.localRotation.x,
currentWeapon.bullet.transform.localRotation.y, currentWeapon.bullet.transform.localRotation.z);
Answer the question
In order to leave comments, you need to log in
You yourself in the 3rd Instantiate argument pass an empty quaternion. This is the turn.
bullet.transform.localEulerAngles = new Vector3(currentWeapon.bullet.transform.localRotation.x,
currentWeapon.bullet.transform.localRotation.y, currentWeapon.bullet.transform.localRotation.z);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question