纳金网

标题: 请教AngryBots脚本中的几个问题? [打印本页]

作者: 她。    时间: 2013-4-27 09:33
标题: 请教AngryBots脚本中的几个问题?
这几天看了一下AngryBots中的脚本,无奈水平有限有很多问题不明白。在脚本PlayerMoveController里面 Update函数中:

。。。。



// On PC, the cursor point is the mouse position

            var cursorScreenPosition : Vector3 = Input.mousePosition;

                        

            // Find out where the mouse ray intersects with the movement plane of the player

            var cursorWorldPosition : Vector3 = ScreenPointToWorldPointOnPlane (cursorScreenPosition, playerMovementPlane, mainCamera);

            

            var halfWidth : float = Screen.width / 2.0f;

            var halfHeight : float = Screen.height / 2.0f;

            var maxHalf : float = Mathf.Max (halfWidth, halfHeight);

            

            // Acquire the relative screen position            

            var posRel : Vector3 = cursorScreenPosition - Vector3 (halfWidth, halfHeight, cursorScreenPosition.z);        

            posRel.x /= maxHalf;

            posRel.y /= maxHalf;

                        

            cameraAdjustmentVector = posRel.x * screenMovementRight + posRel.y * screenMovementForward;

            cameraAdjustmentVector.y = 0.0;   

                                    

            // 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

    var cameraTargetPosition : Vector3 = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview;

   

    // Apply some smoothing to the camera movement

    mainCameraTransform.position = Vector3.SmoothDamp (mainCameraTransform.position, cameraTargetPosition, cameraVelocity, cameraSmoothing);


这段处理摄像机位置的代码中,变量cameraAdjustmentVector或者说posRel到底是什么意义呢?





欢迎光临 纳金网 (http://course.narkii.com/club/) Powered by Discuz! X2.5