- Home /
OP Insulting those who choose to help.
Cannot convert 'UnityEngine.Quaternion' to 'UnityEngine.Transform'.
So someone gave me this script and he told me that there would be errors because he did it in a hurry .
var shaking : boolean = false;
var OriginalRotation : Transform;
function Update (){
var camera = GameObject.Find("MainCamera");
OriginalRotation=camera.transform.rotation; **// THIS LINE**
OriginalRotation; **// AND THIS LINE**
GameObject.Find("ump").animation.Play("ShootUMP");
if(!shaking){
CamShake ();
}
thats not the enitire script though , it was just a add on . Im new to scripting thanks
Answer by meat5000 · Oct 18, 2013 at 10:02 PM
I'm guessing OriginalRotation is a Transform. It should probably be a Quaternion.
You can't use this site and a line-by-line error message translator. Stop copy/pasting code you don't understand. Go do some tutorials.
He has a point, even if he expressed it tersely.
You should really check the docs first before asking this sort of basic help: http://docs.unity3d.com/Documentation/ScriptReference/Camera.html http://docs.unity3d.com/Documentation/ScriptReference/Animation.html
There is no animation method on Camera that takes a parameter, but you can lookup animation states using array style [] indexing. Change it to camera.animation["CameraShake"].length.
You're welcome! I'm so glad I spent my time solving your problems and pointing you in the right direction. Lesson learned.
How about some thumbs up for the guy that actually threw an answer? :D
It's like an old mothers' meeting!
Edit : Respect :P Thanks
@clunk47 It's actually not the first time that guy is being a totally ungrateful douche bag.
Answer by Huacanacha · Oct 18, 2013 at 10:14 PM
Change:
var OriginalRotation : Transform;
To this:
var OriginalRotation : Quaternion;
Transform.rotation returns a Quaternion, but your variable is a Transform type.
See my answer in the other comment... use camera.animation["CameraShake"].length
Follow this Question
Related Questions
How to do relativte offset rotation 0 Answers
Get my head around Unity Rotations 1 Answer
Rotation direction in coroutine 2 Answers
2D look at 1 Answer