纳金网

标题: Unity3D Ball and Chain 球与链条(二) [打印本页]

作者: 会飞的鱼    时间: 2011-12-21 15:01
标题: Unity3D Ball and Chain 球与链条(二)
Moving skyboxes = multiple cameras.
One of the fastest things to set up is a simple skybox. It creates a visually pleasing backdrop and can add a lot to a game. After looking at a static skybox for a long time, it can get a bit “samey”. A quick look on the official forums and people were suggesting using multiple camera and setting up combinations of Clear Flags and Culling Masks. That’s all pretty easy to sort out, add another camera, I chose to make it a child of my main camera, and set its Clear Flags to “Skybox” and Culling mask to “Nothing”. Setting the main camera Clear Flags to “DepthOnly” and its Culling Mask to “Everything” gave me the correct result in each camera, just the skybox through the child and everything else with a blank area for the Skybox to sit. The problem was the child rendering the skybox on top of everything, the solution?
skyCamera.camera.depth = 1;

mainCamera.camera.depth = 2;Setting the camera depth property programmatically solved the issue. So now the skybox is rendered through a different camera, it’s free to rotate slowly and give you a dynamic backdrop.
Scripted Joints.
An annoying problem with a very simple solution! I wanted the chain to be made out of a varying number of links, so I could create short and long ones out of the same code. Another self-imposed requirement was making something useable out of the physics components. So, dynamic joints and rigidbodies were the order of the day. After messing about with the properties of configurable joints, I couldn’t understand why none of them had any discernable affect on my rigidbodies. One of those classic palm-to-forehead moments ensued when I realised you need to set the connected rigidbody AFTER setting all the variables!
//Set all variables, then:

cJoint.connectedBody = myChild.transform.rigidbody;These were two of the “little things” that caused me frustration, if my solutions solved either of the problems for you, I hope you found this post sooner rather than later!
Check back for more problem based solutions as I develop the project further. If there’s any interest, I’ll post the project source code after each project step. Enjoy!
由 uke发表
作者: tc    时间: 2012-1-27 23:29
笑声,欢天喜地;幸运,铺天盖地;才情,经天纬地;财气,呼天唤地;豪气,遮天盖地;福气,惊天动地;春节,冰天雪地;快乐,翻天覆地!

作者: tc    时间: 2012-4-18 23:20
这么后现代

作者: 晃晃    时间: 2012-5-9 23:23
先垫一块,再说鸟

作者: tc    时间: 2012-7-1 23:21
跑着去顶朋友滴铁

作者: 菜刀吻电线    时间: 2012-9-23 23:43
呵呵,真得不错哦!!

作者: C.R.CAN    时间: 2013-1-31 23:24
很经典,很实用,学习了!

作者: Kadina    时间: 2014-9-26 06:57
Thanks for sharing !
作者: soulhez    时间: 2014-9-26 20:48
老外说会公布源码,但后面没看见源码在哪




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