- Home /
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?
Answer by TheGhost. · May 27, 2012 at 12:54 PM
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)
Your answer
Follow this Question
Related Questions
Keep getting the Error: Camera' does not contain a definition for `mainCamera' 2 Answers
How to make camera position relative to a specific target. 1 Answer
Player move and camera problem 2 Answers
2 Cameras layer wont render till i turn it off/on 0 Answers
Camera.current.Render() renders AND makes a NullReferenceException error 0 Answers