- Home /
Question by
markblank05 · Nov 13, 2015 at 01:33 PM ·
c# to javascript
javascript to c# problem
Hi, I found this script around here about third person control and when I try to convert it to c# it's not working.
var moveVectorX : Vector3 = theCamera.forward * inputY;
var moveVectorY : Vector3 = theCamera.right * inputX;
var moveVector : Vector3 = ( moveVectorX + moveVectorY ).normalized * movementSpeed * Time.deltaTime;
myTransform.position = myTransform.position + Vector3( moveVector.x, 0.0, moveVector.z );
myTransform.LookAt( myTransform.position + Vector3( moveVector.x, 0.0, moveVector.z ) );
and this is what i come up with.
Vector3 moveVectorX = mainCamera.forward * inputY;
Vector3 moveVectorY = mainCamera.right * inputX;
Vector3 moveVector = (moveVectorX + moveVectorY).normalized * moveSpeed * Time.deltaTime;
transform.position = transform.position + Vector3 (moveVector.x, 0f, moveVector.z);
transform.LookAt (transform.position + Vector3 (moveVector.x, 0f, moveVector.z));
Comment
Best Answer
Answer by gjf · Nov 13, 2015 at 01:33 PM
you really need to say what's not working about it, any error messages, etc.
one thing to consider is that when defining the Vector3 from component parts (x/y/z), you should use 'new' so add that to line 5 & 6
Your answer
