var build = Instantiate(buildprefab, transform.position+forward*2+up/2, Quaternion.Euler(0,transform.rotation.y,0));
sorry for the noob question i just started yesterday
the new object dosn’t rotate to the others angle how do you do it?
var build = Instantiate(buildprefab, transform.position+forward*2+up/2, Quaternion.Euler(0,transform.rotation.y,0));
sorry for the noob question i just started yesterday
the new object dosn’t rotate to the others angle how do you do it?
Unity fools us by displaying transform.localEulerAngles in the Inspector under the name Rotation - the actual transform.rotation is a quaternion, whose XYZ components have nothing to do with the euler angles. If you want to copy only the rotation around Y, use eulerAngles.y like this:
var build = Instantiate(buildprefab, transform.position+forward*2+up/2, Quaternion.Euler(0,transform.eulerAngles.y,0));
But be aware that weird Y angles may result when the eulerAngles X and/or Z aren’t zero. This happens because a single quaternion may be converted to several different Euler angles combination ((180,0,180) is the same as (0,180,0), for instance), and sometimes the one chosen by Unity isn’t the one you expect.