Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

How to set a target position in Vector3.MoveTowards using a variable

$
0
0
so i want a target position for my camera to move to be -10 away from the current x position of an object. I got this and got stuck. function moveCamera () { var myVar : double; myVar= GameObject.Find("First Person Controller").transform.position.x; myVar-= 10; transform.position = Vector3.MoveTowards(transform.position, myVar, .05); } The Consoles says that I cannot use myVar in the MoveTowards because it uses a Vector3 but then i cannot subtract the 10 from myVar if it is a vector3. Thank you in advance.

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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