That's perfectly fine for as far as I know, just be careful with using .transform in Updates.
You probably know GetComponent() is heavier on the system than things with variables, right?
Well, .transform is also actually a GetComponent() in disguise.
So you should consider storing the transform in a variable and then using that.
Which ends up in:
Transform mCameraMainTrans;
void Start() {
mCameraMainTrans = Camera.main.transform;
}
void Update() {
mCameraMainTrans.position = Vector3.Lerp(mCameraMainTrans.position, head.position, cameraSlerpPositionSpeed * Time.deltaTime);
mCameraMainTrans.rotation = Quaternion.Lerp(mCameraMainTrans.rotation, head.rotation, cameraSlerpRotationSpeed * Time.deltaTime);
}
So yea, for as far as I know it's pretty valid. However I'd be englightened if told otherwise by a more experienced Unity Programmer, so I'm only 90% sure :)
Also, I've surely seen algorithmic structures that go far far far beyond this and still work out perfectly fine, so you should be fine either way ;)
If you like my answer enough, you can accept it, I'd appreciate it :)
↧