- Home /
2 errors im stuck on.
Im trying to make a strategy camera from following a 1 year old tutorial that is using unity3 but im using unity4. Im getting this error for 2 lines: "No appropriate version of unity.MathF.SmoothDamp' for the argument list (float, System Object, float) was found" ERROR CODE:
var lookSensitivity : float = 3;
@HideInInspector
var currentYRotation : float;
@HideInInspector
var currentXRotation : float;
@HideInInspector
var yRotationV : float;
@HideInInspector
var xRotationV : float;
@HideInInspector
var yRotation : float;
@HideInInspector
var xRotation : float;
var cameraRotationSpeed : float = 0.5;
var cameraTiltSpeed : float = 0.5;
var maxCameraAngle : float = 40;
var minimumCameraAngle : float = 50;
var lookSmoothDamp : float = 0.2;
function Update ()
{
currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation.xRotationV, lookSmoothDamp);
}
Also i have this error "The Type 'UnityEngine.Vector2.does not have a visible constructor that matched the argument list '(System.Object)'. ERROR CODE.
var movementAccel : float = 10000;
var movementSlowDownSpeed : float = 0.1;
var movementSlowDownSpeedx : float;
var movementSlowDownSpeedz : float;
var cameraObj : GameObject;
var maxMovementSpeed : float = 25;
var horizontalMovement : Vector2;
var maxSlope : float = 90;
function LateUpdate ()
{
horizontalMovement = Vector2(rigidbody.velocity.x.rigidbody.velocity.z);
}
I would be thankfull if anyone can share there knowledge on this and teach me how to fix it.
If you still have any doubts do leave them in the comments and i would glady help you
and i would like to know that is currentXRotation and XRotation , xRotationV as well as lookSmoothDamp actually as i donot see any variables declared like that declared in your script.
Also you are using CurrentXRotation without declaring it first. You should declared it first outside function Update and then you can assign value to it.
Sorry about the variables typo, now my variables im showing you above is correct.
Thanks for fixing the second error for me... I have a problem with the first one still though. are you saying i cannot use my variables in $$anonymous$$athF.SmoothDamp?
$$anonymous$$athf.SmoothDamp always takes float arguments. So ofcourse you can use variables with it. The Variables should be of type float otherwise you will need to cast them to float.
You cannot use xRotation.xRotationV as this is not valid ins$$anonymous$$d just use one variable there. For example use only xRotation or use only xRotationV. And also $$anonymous$$athf.SmoothDamp takes four arguments at $$anonymous$$imum not three
Check the refrence doc here to get the more idea about $$anonymous$$athf.SmoothDamp http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$athf.SmoothDamp.html
If still have any doubt do post as a comment
Thanx for your help and time.
this is the script that worked.
currentXRotation = $$anonymous$$athf.SmoothDamp(currentXRotation, xRotation,xRotationV, lookSmoothDamp);
.z);
i had a full stop inbetween xRotation,xRotationV.
Answer by tuhinbhatt · Feb 17, 2013 at 03:05 PM
Here is the solution of second error you are getting about Vector2
You are missing a comma in line 13 it should be
horizontalMovement=Vector2(rigidbody.velocity.x,rigidboy.velocity.y);
and not
horizontalMovement = Vector2(rigidbody.velocity.x.rigidbody.velocity.z);
And For the error in MathF.SmoothDamp you are using this code
Mathf.SmoothDamp(currentXRotation, xRotation.xRotationV, lookSmoothDamp);
There is mistake in your second argument that is xRotation.xRotationV. It should not be like that. Mathf.SmoothDamp takes this arguments actually
Mathf.SmoothDamp(float current, float target, ref float current velocity,float smoothtime);
It actually also overrides with other two arguments they are
Mathf.SmoothDamp(float current, float target, ref float current velocity,float smoothtime,float maxSpeed);
And
Mathf.SmoothDamp(float current, float target, ref float current velocity,float smoothtime,float maxSpeed,float deltatime);
Do remember each and every argument in Mathf.SmoothDamp is float.
Your answer
Follow this Question
Related Questions
errror message 1 Answer
unity say's: expecting :, found '='. 2 Answers
GUI.Box error 1 Answer
Strange error with unity. 1 Answer