马上注册,加入CGJOY,让你轻松玩转CGJOY。
您需要 登录 才可以下载或查看,没有帐号?立即注册
×
老外蛮有一意思的一个练习,可以调整旋转速度,及轴的高低,并可将链条上的球高速抛出。具体效果在教程最后。
Making the transition from Flash and ActionScript to Unity and its JavaScript/C# has been very smooth, thanks to their detailed scripting reference and very active forums. Being one of those people when faced with flat-pack to assemble, grabs a hammer and gets stuck-in, there have been plenty of sticking points which have had me reaching for the instructions.
This is a tech demo of Unity that was created over the weekend to overcome some of the challenges that might arise when working on commercial Unity work. Initially it was created as a one off, but after finding and solving quite a few problems, I thought it might be nice to share my solutions to some of these problems as I develop the project in my spare time.
Controls: Up & Down (or W & S) to raise or lower the spinner, scroller adjusts spinning speed, and Space Bar to release the ball.
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!
|