查看: 1428|回复: 0
打印 上一主题 下一主题

请教AngryBots脚本中的几个问题?

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-4-27 09:33:15 |只看该作者 |倒序浏览
这几天看了一下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到底是什么意义呢?
,
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-22 05:37 , Processed in 0.114176 second(s), 33 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部