当前位置:网站首页>Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
2022-07-07 15:52:00 【Le_ Sam】
background , Recently took over a project , Fishing like game , The demand is that the bullet can rebound in the surrounding wall after being fired , You can refer to another article about rebound . Because the screen aspect ratio of different models is different , Therefore, it is necessary to adapt to the distance between walls . as everyone knows ,U3d Of Camera When the camera changes the viewport , The upper and lower edges are unchanged , Only the left and right edges will be close to or away from each other . The same goes for mobile screen , The left and right edges of the widescreen mobile phone are far away one after another , The left and right edges of tablet phones are close one after another . Therefore, after knowing the screen resolution of the mobile phone , Next, just change the yellow arrow wall
-- The wall adapts to different screens , remarks :GreatWallMgr.LeftWall And GreatWallMgr.RightWall Left and right walls
function GreatWallMgr.InitAdaptionWall()
-- Benchmark scale 1136:640 == 71:40, My project is based on 1136:640 Adapt to different resolutions for Standards
log("Height: " .. tostring(curCamera.pixelHeight))
log("Width: " .. tostring(curCamera.pixelWidth))
local curHeight = curCamera.pixelHeight
local curWidth = curCamera.pixelWidth
local Dwidth = 71*curHeight/40 -- Difference value
local Pwidth = (curWidth - Dwidth)/Dwidth -- Percentage of actual width to base width ,+ To exceed the benchmark ,- Is less than the benchmark
local leftPos = GreatWallMgr.LeftWall.position
local rightPos = GreatWallMgr.RightWall.position
--log(tostring(Pwidth) .. " Pwidth")
local wallDis = Vector3.Distance(leftPos, rightPos);
--log(tostring(wallDis) .. " wallDis")
local dPos = wallDis * Pwidth / 2
--log(tostring(dPos) .. " dPos")
GreatWallMgr.LeftWall.position = Vector3(leftPos.x - dPos, 0, leftPos.z);
GreatWallMgr.RightWall.position = Vector3(rightPos.x + dPos, 0, rightPos.z);
end
边栏推荐
- 深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
- VS2005 strange breakpoint is invalid or member variable value cannot be viewed
- Three. JS introductory learning notes 11:three JS group composite object
- 【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
- Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
- Ue4/ue5 multi thread development attachment plug-in download address
- Tkinter after how to refresh data and cancel refreshing
- Mesh merging under ue4/ue5 runtime
- 保证接口数据安全的10种方案
- [Lanzhou University] information sharing of postgraduate entrance examination and re examination
猜你喜欢
webgl_ Enter the three-dimensional world (1)
Numpy --- basic learning notes
Spin animation of Cocos performance optimization
Write sequence frame animation with shader
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
Introduction of mongod management database method
numpy--数据清洗
有钱人买房就是不一样
Whole process analysis of unity3d rendering pipeline
随机推荐
TS as a general cache method
JS array foreach source code parsing
How to create Apple Developer personal account P8 certificate
[original] all management without assessment is nonsense!
Android -- jetpack: the difference between livedata setValue and postvalue
numpy---基础学习笔记
It's different for rich people to buy a house
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
Do not use memset to clear floating-point numbers
15. Using the text editing tool VIM
Webgl texture
[wechat applet] Chapter (5): basic API interface of wechat applet
A wave of open source notebooks is coming
Numpy --- basic learning notes
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
[quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
Three. JS introductory learning notes 18: how to export JSON files with Blender
Points for attention in porting gd32 F4 series programs to gd32 F3 series
Getting started with webgl (4)