当前位置:网站首页>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
边栏推荐
- Shader Language
- numpy---基础学习笔记
- Write sequence frame animation with shader
- 15. Using the text editing tool VIM
- Migration and reprint
- [quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)
- Iterator and for of.. loop
- Three. JS introductory learning notes 18: how to export JSON files with Blender
- C4D learning notes 3- animation - animation rendering process case
- 2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
猜你喜欢
Postman generate timestamp, future timestamp
Tkinter after how to refresh data and cancel refreshing
15. Using the text editing tool VIM
Numpy --- basic learning notes
Monthly observation of internet medical field in May 2022
Three. JS introductory learning notes 10:three JS grid
Three. JS introductory learning notes 15: threejs frame animation module
Three. JS introductory learning notes 05: external model import -c4d into JSON file for web pages
Asynchronous application of generator function
神经网络c语言中的指针是怎么回事
随机推荐
Postman generate timestamp, future timestamp
[quick start of Digital IC Verification] 24. AHB sramc of SystemVerilog project practice (4) (AHB continues to deepen)
强化实时数据管理,英方软件助力医保平台安全建设
Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
C4D learning notes 2- animation - timeline and time function
Streaming end, server end, player end
20th anniversary of agile: a failed uprising
Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
Syntax of generator function (state machine)
Mesh merging under ue4/ue5 runtime
How to deploy the super signature distribution platform system?
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
Summary of knowledge points of xlua hot update solution
After UE4 is packaged, mesh has no material problem
How to create Apple Developer personal account P8 certificate
Getting started with webgl (2)
unnamed prototyped parameters not allowed when body is present
Basic knowledge sorting of mongodb database
OpenGL common functions