So, I’m currently porting some js scripts from Unity3D examples to C#, and one of the errors I’m getting is this : Cannot implicitly convert type void to UnityEngine.Vector3
Here’s a screenshot and the script by the way
void Update () {
//Character movement direction
motor.movementDirection = Input.GetAxis ("Horizontal") * screenMovementRight + Input.GetAxis ("Vertical") * screenMovementForward;
//Make sure the direction vector doesn't exceed a length of 1
// so the character can't move faster diagonally than horitonally or vertically
if (motor.movementDirection.sqrMagnitude > 1)
{
motor.movementDirection.Normalize();
}
//Character facing direction and screen focus point
//First update the camera position to take into account how much the character moved since last frame
//mainCameraTransform.position = Vector3.Lerp (mainCameraTransform.position, character.position + cameraOffset, Timpe.deltaTime * 45.0f * deathSmoothoutMultiplier);
//Set up the movement plane of the character, so screenpositions
//can be converted into world positions on this plane
//playerMovementPlane = new Plane (Vector3.up, character.position + character.up * cursorPlaneHeight);
//optimization (instead of newing Plane)
playerMovementPlane.normal = character.up;
playerMovementPlane.distance = -character.position.y + cursorPlaneHeight;
//used to adjust the camera based on cursor
Vector3 cameraAdjustmentVector = Vector3.zero;
float axisX = Input.GetAxis("LookHorizontal");
float axisY = Input.GetAxis("LookVertical");
motor.facingDirection = ((axisX * screenMovementRight) + (axisY * screenMovementForward));
cameraAdjustmentVector = motor.facingDirection;
//On PC, the cursor point is the mouse position
Vector3 cursorScreenPosition = Input.mousePosition;
//Find out where the mouse ray intersects with the movement plane of the player
Vector3 cursorWorldPosition = ScreenPointToWorldPointOnPlane (cursorScreenPosition, playerMovementPlane, mainCamera);
float halfWidth = Screen.width / 2.0f;
float halfHeight = Screen.height / 2.0f;
float maxHalf = Mathf.Max (halfWidth, halfHeight);
//Acquire the relative screen position
Vector3 toMath = (halfWidth, halfHeight, cursorScreenPosition.z);
Vector3 posRel = cursorScreenPosition - (Vector3 (halfWidth, halfHeight, cursorScreenPosition.z));
posRel.x /= maxHalf;
posRel.y /= maxHalf;
cameraAdjustmentVector = posRel.x * screenMovementRight + posRel.y * screenMovementForward;
cameraAdjustmentVector.y = 0.0f;
//The facing direction is the direction from the character to the cursor world position
motor.facingDirection = (cursorWorldPosition - character.position);
motor.facingDirection.y = 0;
//Draw the cursor nicely
HandleCursorAlignment (cursorWorldPosition);
//Handle camera position
//Set the target position of the camera to point at the focus point
Vector3 cameraTargetPosition = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview;
//Apply some smoothing to the camera movement WTF IS "ref" in cameraVelocity
mainCameraTransform.position = Vector3.SmoothDamp (mainCameraTransform.position, cameraTargetPosition, ref cameraVelocity, cameraSmoothing);
//Save camera offset so we can use it in the next frame
cameraOffset = mainCameraTransform.position - character.position;
}