[英]Unity3D objects creating
I'm very new in Unity3D. 我是Unity3D的新手。 How can I creating objects, in example, spheres during the game? 如何在游戏过程中创建对象,例如球体? I'm found this JavaScript code: 我找到了以下JavaScript代码:
var projectile : Rigidbody;
var speed = 20;
function Update()
{
if( Input.GetKeyDown( KeyCode.Mouse0 ) )
{
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
}
}
Will this script create object, that will be moving? 此脚本会创建将移动的对象吗? Suppose this script is that I need, that I need to do with it after? 假设这个脚本是我需要的,之后我需要使用它吗? When I was programming movement of sphere I attached script to my sphere. 当我对球体的运动进行编程时,我将脚本附加到了我的球体上。
Yes it instantiate rigibodies by clicking 0 in keyboard. 是的,它通过单击键盘中的0实例化rigibody。 And collision doesnt detect 碰撞无法检测
For more information go through 有关更多信息,请通过
http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreCollision.html http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreCollision.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.