Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

i am making a mario clone in my class and i keep getting this error (11,52): error CS0029: Cannot implicitly convert type `UnityEngine.Vector3' to `float'

$
0
0
if anyone can help me out would be appreciated, does it mean you can't use a vector3 in this line of code? I wrote it out just like my teacher put it, but not sure why am getting the error - and of course I can't move on with the assignment without fixing this error - I have rewritten it many times just in case I missed something - but still get the error code. thanks in advance using UnityEngine; using System.Collections; public class Camerafollow : MonoBehaviour { public Transform target; public Transform leftBounds; public Transform rightBounds; public float smoothDampTime = 0.15f; private float smoothDampVelocity = Vector3.zero; private float camWidth, camHeight, levelMinX, levelMaxX; // Use this for initialization void Start () { camHeight = Camera.main.orthographicSize * 2; camWidth = camHeight * Camera.main.aspect; float leftBoundsWidth = leftBounds.GetComponentInChildren ().bounds.size.x / 2; float rightBoundsWidth = rightBounds.GetComponentInChildren ().bounds.size.x / 2; levelMinX = leftBounds.position.x + leftBoundsWidth + (camWidth / 2); levelMaxX = rightBounds.position.x - rightBoundsWidth - (camWidth / 2); } // Update is called once per frame void Update () { if (target) { float targetX = Mathf.Max (levelMinX, Mathf.Min (levelMaxX,target.position.x)); float x = Mathf.SmoothDamp(transform.position.x, targetX, ref smoothDampVelocity, smoothDampTime); transform.position = new Vector3(x, transform.position.y, transform.position.z); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>