x


Error in Camera Tutorial that I can't seem to get right.

I was following a tutorial by WalkerBoy Studios about Cameras. I have an error:

Assets/2D Mario Assets/Scripts/cameraSmoothFollow2D.js(24,61): BCE0023: No appropriate version of 'UnityEngine.Mathf.SmoothDamp' for the argument list '(float, float, UnityEngine.Vector2, float)' was found.

var cameraTarget         :    GameObject;         

var smoothTime          : float = 0.1;       
var cameraHeight         :    float = 2.5;     

var cameraFollowX      :   boolean =  true;  

var velocity          :   Vector2;

private var thisTransform           : Transform;

function Update ()
{
    if( cameraFollowX){

       thisTransform.position.x =  Mathf.SmoothDamp(thisTransform.position.x, cameraTarget.transform.position.x, velocity, smoothTime);}}

I know that the problem is the 3rd variable being a Vector 2. But in the tutorial it makes velocity a Vector 2. But how would fix this problem but have the same result as the tutorial?

more ▼

asked May 26 '12 at 08:00 PM

TheGhost. gravatar image

TheGhost.
6 3 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The answer was because I set the velocity to Vector 2 but I didn't put the X value into velocity

making the code to be: thisTransform.position.x = Mathf.SmoothDamp(thisTransform.position.x, cameraTarget.transform.position.x, velocity.x, smoothTime),The answer was because I set the velocity to Vector 2 but I didn't put the position of X

making the code to be: thisTransform.position.x = Mathf.SmoothDamp(thisTransform.position.x, cameraTarget.transform.position.x, velocity.x, smoothTime)

more ▼

answered May 27 '12 at 12:54 PM

TheGhost. gravatar image

TheGhost.
6 3 6

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3014
x1951
x45

asked: May 26 '12 at 08:00 PM

Seen: 381 times

Last Updated: May 27 '12 at 12:54 PM