- Home /
Extraction of Coordinate and Scaling it down by half.
Hi, I'm trying to extract the coordinates(x, z) of a first person controller and scale it down by half and pass it to another game object to somehow make the GO move the same direction as the first person controller just that the distance is shorten by half. Is this possible? I need help.. Thanks! ):
Answer by Mike 3 · Jun 30, 2010 at 08:31 AM
Something like this should do it:
var controlledObject : Transform; //drag your other object here in the inspector
function Update() { var pos = transform.position; pos.Scale(Vector3(0.5, 1.0, 0.5)); //sets the coordinates to be half the original in x&z controlledObject.position = pos; }
Thanks for the reply! (: But I was prompted this error.
Assets/$$anonymous$$ovement1.js(6,10): BCE0023: No appropriate version of 'UnityEngine.Vector3.Scale' for the argument list '(float, int, float)' was found.
I've got no clue what is it about. Sorry. ><
It has the same error. ):
Assets/$$anonymous$$ovement1.js(6,10): BCE0023: No appropriate version of 'UnityEngine.Vector3.Scale' for the argument list '(float, float, float)' was found.
Fixed and tested properly this time (This is why I shouldn't code at 5am)