2D地圖攝像機
創建一個平面幾何體(plane.mesh),設置地圖紋理材質創建一個正交攝像機,視口朝向地圖俯視設置地圖Layer類型為map,設置攝像機Visibility為只可見map
編輯器中效果圖
3D人物攝像機
設置一個3D主攝像跟隨玩家設置攝像機Visibility值為只可見avatar,并讓攝像機以x軸逆時針旋轉45度,視口用腳本自動朝向人物動態創建的玩家設置Layer為avator
運行時效果圖
界面小地圖攝像機
在人物模型頭頂設置一個俯視的透視攝像機,設置Visibility值只可見avatar、map設置攝像機的targetTexture屬性獲取動態渲染的數據將渲染的數據設置到Sprite組件中
運行效果圖
const colorAttachment
= new gfx.ColorAttachment();const depthStencilAttachment
= new gfx.DepthStencilAttachment();const pi
= new gfx.RenderPassInfo([colorAttachment
], depthStencilAttachment
, []);this.rt
.reset({width
: w
,height
: h
,passInfo
: pi
});let spriteframe
: SpriteFrame
= this.sprite
!.spriteFrame
!;let sp
: SpriteFrame
= new SpriteFrame();sp
.reset({originalSize
: spriteframe
.originalSize
,rect
: spriteframe
.rect
,offset
: spriteframe
.offset
,isRotate
: spriteframe
.rotated
,borderTop
: spriteframe
.insetTop
,borderLeft
: spriteframe
.insetLeft
,borderBottom
: spriteframe
.insetBottom
,borderRight
: spriteframe
.insetRight
,});this.camera
!.targetTexture
= this.rt
;sp
.texture
= this.rt
;this.sprite
!.spriteFrame
= sp
;
總結
以上是生活随笔為你收集整理的Cocos Creator 3.2 中实现2D地图3D人物45度角RPG游戏效果笔记(摄像机设置方案)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。