Hello unity community, (RHYMES!)
So I tried to translate a javascript script to a C# script and it gives me an error and I tried looking it up, even came up with some imaginary solutions but nothing worked so far..
using UnityEngine;
using System.Collections;
public class CamFollow : MonoBehaviour {
private Transform camfollow;
public float camSpeed = 0.3f;
private Transform thisTransform;
private Vector3 velocity;
// Use this for initialization
void Start () {
thisTransform = transform;
}
// Update is called once per frame
void Update () {
thisTransform.position.x = Mathf.SmoothDamp (thisTransform.position.x, camfollow.position.x,
ref velocity.x, camSpeed);
thisTransform.position.z = Mathf.SmoothDamp (thisTransform.position.z, camfollow.position.z,
ref velocity.z, camSpeed);
}
}
Here’s the code and here’s the error
`UnityEngine.Transform.position’. Consider storing the value in a temporary variable
Thanks in advance ![]()
PS: I’m new to this so be easy on me, an explanation would be great aswell